Hi, I need to check if i have a specific file named positions1, positions2, positions3,…
I thought I could combine a string with an integer and then write something like
File nameofString+number= new File(sketchPath())
however this doesn’t seem to work.
If you have any good ideas how I can solve this problem I would really appreciate if you could help.
Thank you for taking the to time answer
Create a \data folder in your sketch with some various file types.
This example will list the files and then do a check:
// Files and directories
// v1.0.0
// GLV 2022-08-27
void setup()
{
size(200, 200);
println(sketchPath());
println(dataPath(""));
// List file names in \data folder
File f = new File(dataPath(""));
println(f);
printArray(f.list());
// Check if a file exists
f = dataFile("New Text Document.txt"); // Checks for this file name
if (f.exists())
println("exists");
else
println("! exists");
f = dataFile("positions"); // Checks for this file name
if (f.exists())
println("exists");
else
println("! exists");
noLoop();
}