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