This tutorial picks up where the Strings and Drawing Text tutorial leaves off and examines how to use String objects as the basis for reading and writing data. We'll start by learning more sophisticated methods for manipulating Strings, searching in them, chopping them up, and joining them together. Afterwards, we'll see how these skills allow us to use input from data sources, such as text files, web pages, xml feeds, and 3rd party APIs and take a step into the world of data visualization.

Consider the following array:
String[] lines = {"It", "was", "a", "dark", "and", "stormy", "night."}; Using the “+” operator along with a for loop, you can join a string together as follows:
// Manual Concatenation String onelongstring = ""; for (int i = 0; i < lines.length; i++) { onelongstring = onelongstring + lines[i] + " "; } The join() function, however, allows you to bypass this process, achieving the same result in only one line of code.
// Using Processing's join() String onelongstring = join(lines, " ");

Data can come from many different places: websites, news feeds, spreadsheets, databases, and so on. Let's say you've decided to make a map of the world's flowers. After searching online you might find a PDF version of a flower encyclopedia, or a spreadsheet of flower genera, or a JSON feed of flower data, or a REST API that provides geolocated lat/lon coordinates, or some web page someone put together with beautiful flower photos, and so on and so forth. The question inevitably arises: “I found all this data; which should I use, and how do I get it into Processing?”


bookmarkden.info
4165lYsvHJL