Saving a String, loading the text file and saving more informations to it?
in
Programming Questions
•
2 years ago
Hi
Well, title explains it basicly.
For instance, the loaded file is sth like:
.. but it just saves 3 lines and delets the old ones.
Theres the code so far:
thx
cheers
Well, title explains it basicly.
For instance, the loaded file is sth like:
- 40 50
- 60 34
- 60 34
- 60 34
- 40 50
- 60 34
- 45 68
- 60 34
- 60 34
.. but it just saves 3 lines and delets the old ones.
Theres the code so far:
- PrintWriter output;
- String[] loadInfos;
- void setup(){
- size(300,300);
- loadInfos = loadStrings("old.txt");
- }
- void draw(){
- background(255);
- }
- void keyPressed(){
- if(key == 's') {
- String[] wo = loadInfos;
- output = createWriter("old.txt");
- for(int i = 0; i < wo.length; i++){
- print(wo[i] + "\n" + mouseX + "\t" + mouseY+ "\n");
- String words = (wo[i] + "\n" + mouseX + "\t" + mouseY+ "\n");
- //String[] words = {wo[i]};
- output.print(words);
- output.flush(); // Writes the remaining data to the file
- output.close();
- }
- //wo = wo + "\n" + mouseX + "\t" + mouseY;
- //saveStrings("old.txt", wo);
- }
- }
thx
cheers
1