Select output of printWriter

hello! how can i save the printWriter object inside a custom folder?

wr = createWriter("obj"+ index + "txt");

i want to create a folder inside a sketch and save the files there.
Thanks!

you give a filename or a path & filename
so actually if you make that sketch
and pls. first save it…


PrintWriter output;
String s = "Hallo World";

void setup() {
  output = createWriter("data/mytext.txt");
}

void draw() {
}

void keyPressed() {
  output.println(s);
  output.flush(); // Writes the remaining data to the file
  output.close(); // Finishes the file
  exit(); // Stops the program
}

and you RUN it and press any key
the (sub) directory and file is created.
( tested linux RASPBIAN and processing 3.4 )

1 Like