Java Reference
In-Depth Information
case
case 's' : finder . filter . setSizeFilter ( argHandler . optarg ()); break
break ;
default
default :
System . out . println ( "Got: " + c );
usage ();
}
}
iif ( args . length == 0 || argHandler . getOptInd ()- 1 == args . length ) {
finder . doName ( "." );
} else
else {
for
for ( int
int i = argHandler . getOptInd ()- 1 ; i < args . length ; i ++)
finder . doName ( args [ i ]);
}
}
protected
protected FindFilter filter = new
new FindFilter ();
public
public static
void usage () {
System . err . println (
"Usage: Find [-n namefilter][-s sizefilter][dir...]" );
System . exit ( 1 );
static void
}
/** doName - handle one filesystem object by name */
private
private void
void doName ( String s ) {
Debug . println ( "flow" , "doName(" + s + ")" );
File f = new
new File ( s );
iif (! f . exists ()) {
System . out . println ( s + " does not exist" );
return
return ;
}
iif ( f . isFile ())
doFile ( f );
else
else if ( f . isDirectory ()) {
// System.out.println("d " + f.getPath());
String objects [] = f . list ( filter );
for
for ( String o : objects )
doName ( s + File . separator + o );
} else
else
System . err . println ( "Unknown type: " + s );
}
/** doFile - process one regular file. */
private
private static
void doFile ( File f ) {
System . out . println ( "f " + f . getPath ());
static void
Search WWH ::




Custom Search