Find files recursively

. 1  public  class BianLiFile {
 2      public  static  void main (String [] args) {
 . 3          // delete only single-stage or directory rename operation 
. 4          the getFile ( " D: \\ " );
 . 5      }
 . 6  
. 7      // to operate in multiple
 8      // all files in the acquired multi-level directory 
. 9      public  static  void the getFile (String path) {
 10          file file = new new file (path);
 . 11          // if only a file or does not exist, returns 
12          IF (file.isFile () ||! File.Exists ()) {
13              // If not, the file does not exist or 
14              return ;
 15          }
 16          File [] = Files File.listFiles ();
 . 17          for (file1 File: Files) { // if a file 
18 is              IF (file1.isFile ()) {
 . 19                  . the System OUT .println ( " file " + file1.getName ());
 20 is              }
 21 is              the else {
 22 is                  the System. OUT .println ( " directory: " + file1.getName ());
 23 is                 getFile(file1.getPath());
24 
25             }
26         }
27     }
28 }

 

Guess you like

Origin www.cnblogs.com/rzkwz/p/12632903.html
Recommended