create writer creates a file at the sketch directory, how can I change the directory?

I have this:

  //records where data is being saved to
    print("saving " + save_name +" to ..//programming_year1//io");

    //I will create a printWriter object for writing text to a file, this
    //will save me from having to first a String array as I would with 'saveStrings()'
    PrintWriter out = createWriter(save_name+".txt");

But its annoying that it doesn't save into a file I have stored in the sketch dorectory called 'io'

Answers

  • Answer ✓

    Sketch's folder is variable sketchPath. So for a folder called "io" that'd be:
    sketchPath + "/io"

    If you prefer the official subfolder "/data/" that'd be: dataPath("io").
    Or even dataFile("io") for a File object! ;)

Sign In or Register to comment.