Look at the example LoadFile1 in menu->examples->topics FileIO
FileIO means input / output of files.
A text file is a collection of text, chars, numbers.
To read a file automatically we need to know how the data in the file is formatted.
Seperation can be newline, space, comma.
We will explore different techniques to get the numbers out of the file.
Maybe we can read the data in, but have to store them in a special way. Then we make our own "class". The class being an abstract structure.
An example Class can be a record of a name and an age.
class Record {
String name;
int age;
}
every time we do
Record person1 = new Record ( "Karel de Grote", 44 );
So we store age and name in this "record".
We can also make arrays of these Records:
Record[] persons = new Record [50];
Now we can store 50 of these persons.
Much more complex Classes can be made the same way.
The most used way nowadays to format data is XML.
Processing has an datastructure called XMLElement.
See this page:
http://processing.org/reference/XMLElement.html
With XML we can get the data from for instance twitter and display the tweets as text.
See this former post about that:
http://flashscriptingwonders.blogspot.com/2011/01/processing-and-twitter.html
A minimal XML example can be found here:
http://www.learningprocessing.com/tutorials/simpleML/
This is a library for doing yahoo searches:
http://www.learningprocessing.com/tutorials/yahoo/
Aucun commentaire:
Enregistrer un commentaire