5, folder Related:
1) staic file[] Listroots () lists all the root directories (the letter for All systems in window)
Example:
File[] roots = File.listroots (); Lists all the root for
(file file : Roots) {
System.out.println (file);
}
2 list () returns the file or directory name in the directory containing the hidden files. This action returns null for the file.
Example:
string[] FileNames = File.list ();
/* Stores all child file names and subfolder names below the current folder in a string type array. */For
(String filename:filenames) {
System.out.println (fileName);
}
3) Listfiles () returns a file or directory object (instance of the file class) in the directory containing hidden files. This action returns null for the file.
Example:
file[] files = file.listfiles (); /* Use a File object description for all subfolders and subfolders below the current folder, and then store the file objects in a file array to return the */for
(file fileitem:files) {
System.out.println ("Wennan:" +fileitem.getname ());
}
4) List (FilenameFilter filter) returns a child file or subdirectory that matches the filter criteria in the current directory. This action returns null for the file.
5) Listfiles (FilenameFilter filter) returns a child file or subdirectory that matches the filter criteria in the current directory. This action returns null for the file.
Example:
The two methods are similar, except that the return value of the list is of type string.