createWriter(); and createReader();
in
Programming Questions
•
2 years ago
I got createWriter(); and createReader(); in a .pde. the wirter works but it dont Reade the date from the txt.
What im doing wrong?
Here my code:
float distanz;
PrintWriter output;
BufferedReader reader;
String line;
void setup (){
size(500,500);
smooth();
output = createWriter("positions.txt");
reader = createReader("positions.txt");
}
void draw (){
if (mousePressed && (mouseButton == LEFT)) {
ellipse(mouseX,mouseY,50,50);
point(mouseX, mouseY);
output.print(mouseX + " " + mouseY+" ");
output.flush();
}
try {
String line;
while ((line = reader.readLine()) != null) {
String[] pieces = split(line, TAB);
int x = int(pieces[0]);
int y = int(pieces[1]);
ellipse(x, y, 50, 50);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
PrintWriter output;
BufferedReader reader;
String line;
void setup (){
size(500,500);
smooth();
output = createWriter("positions.txt");
reader = createReader("positions.txt");
}
void draw (){
if (mousePressed && (mouseButton == LEFT)) {
ellipse(mouseX,mouseY,50,50);
point(mouseX, mouseY);
output.print(mouseX + " " + mouseY+" ");
output.flush();
}
try {
String line;
while ((line = reader.readLine()) != null) {
String[] pieces = split(line, TAB);
int x = int(pieces[0]);
int y = int(pieces[1]);
ellipse(x, y, 50, 50);
}
}
catch (Exception e) {
e.printStackTrace();
}
}
1