thieumao

Scan Folder Demo

Sep 25th, 2013
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package scandemo;
  6.  
  7. import java.io.File;
  8.  
  9. /**
  10.  *
  11.  * @author Thieu Mao
  12.  */
  13. public class Scan {
  14.  
  15.     public static void main(String[] args) {
  16.         ScanFolder("D:\\");
  17.     }
  18.  
  19.     private static void ScanFolder(String myDirectoryPath) {
  20.         File dir = new File(myDirectoryPath);
  21.         for (File child : dir.listFiles()) {
  22.             String str = child.getName();
  23.             if (child.isDirectory()) {
  24.                 ScanFolder(myDirectoryPath + "\\" + str);
  25.             } else {
  26.                 System.out.println(str);
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment