selectInput()
Allow user to select a file using dialog.- Similarly you can use
selectFolder()
to allow user to select a folder. - Once you have the path. You can load the contents using
loadStrings()
orloadBytes()
loadStrings()
Reads the contents of a file or url and creates a String array of its individual lines.- Try: Load and display the contents of a file selected by user.
String loadPath = selectInput(); // Opens file chooser
if (loadPath == null) {
println("cancelled...");
} else {
println(loadPath);
//do something with this file
}
String lines[] = loadStrings("list.txt");
println("there are " + lines.length + " lines");
for (int i=0; i < lines.length; i++) {
println(lines[i]);
}