API Methods
File = File new new File (path); # Create a file object, point to a directory file.exists () # determine whether the directory or file exists File [] Files = File.listFiles (); # Get the current directory and all the files in the directory f.isDirectory () # judge is a directory or file f.getAbsolutePath () # get the absolute file path
Use demo,
public static List <String> getFileName (the dir String, List <String> the fileList) { // the dir string into File file object, using the api implementation requirements File File file = new new File (the dir); // use file method listFiles (), return all the file directory + (just in the current directory, subdirectory is not included) in this path file [] = files File.listFiles (); for (file F: files) { IF (f.isDirectory ()) { // recursive // must have an end condition, for loop will eventually end, the method returns getFileName (f.getAbsolutePath (), the fileList); } the else { fileList.add (f.getAbsolutePath ()); // } } return fileList; }