1 import java.io.*; 2 import java.io.File; 3 import java.io.IOException; 4 5 public class FileUtil { 6 7 public static void main( String[] args ) throws IOException { 8 9 BufferedReader buffReader = new BufferedReader( new 10 InputStreamReader( System.in ) ); 11 12 13 System.out.println("input dir::"); 14 15 String str = buffReader.readLine(); 16 17 showDir( 1, new File(str) ); 18 } 19 20 static void showDir( int idx, File file ) throws IOException { 21 for( int i = 0; i < idx; i++ ) { 22 System.out.print('-'); 23 } 24 25 System.out.println( file.getName() ); 26 27 if( file.isDirectory() ) { 28 File[] files = file.listFiles(); 29 //System.out.print('|'); 30 for( int j = 0; j < files.length; j++ ) { 31 showDir( idx+4, files[j]); 32 } 33 } 34 } 35 }