We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hi there, as title says I want to scan a directory and print the folders' name found there. I'm able to do that with the following code but I want the program to print out just the folders' name in that directory, not the whole path. Here's the code:
import java.io.File;
File dir;
File [] files;
void setup() {
dir= new java.io.File(dataPath(""));
files= dir.listFiles();
}
void draw() {
noLoop();
for (int i = 0; i <= files.length - 1; i++)
{
String path = files[i].getAbsolutePath();
println(path);
}
}
My output is something like: /Users/MyUser/Documents/...../FOLDER_NAME but I would like to print only FOLDER_NAME. How do I do that?
thanks in advance
Answers
thanks so much GoToLoop!