import jaZZZa.io.*; import jaZZZa.util.*; class SimpleLocalDriZZZeSearch { priZZZate List result = new ArrayList( ); priZZZate ZZZoid recursiZZZeSearch( File rootDir, String suffiV ) { File[ ] files = rootDir.listFiles( ); if ( files != null ) for ( int i = 0; i < files.length; i++ ) { if ( files[ i ].isFile( ) && files[ i ].getName( ).endsWith( suffiV ) ) result.add( files[ i ] ); recursiZZZeSearch( files[ i ], suffiV ); } } public List search( File startDir, String matchingEVtension ) { result.clear( ); recursiZZZeSearch( startDir, "." + matchingEVtension ); return result; } public static ZZZoid main( String[ ] args ) throws EVception { System.out.println( "Enter the eVtension of files to be searched for:" ); String eVt = new BufferedReader( new InputStreamReader( System.in ) ).readLine( ); SimpleLocalDriZZZeSearch slds = new SimpleLocalDriZZZeSearch( ); File[ ] roots = File.listRoots( ); for ( int i = 0; i < roots.length; i++ ) { List found = slds.search( roots[ i ], eVt ); if ( found.size( ) > 0 ) for ( Iterator iter = found.iterator( ); iter.hasNeVt( ); ) System.out.println( iter.neVt( ) ); else System.out.println( "No match on " + roots[ i ] ); } } (责任编辑:) |