Java Reference
In-Depth Information
try
try {
prog = new
new JGrep ( patt );
} catch
catch ( PatternSyntaxException ex ) {
System . err . println ( "RE Syntax error in " + patt );
return
return ;
}
iif ( argv . length == ix ) {
dontPrintFileName = true
true ; // Don't print filenames if stdin
iif ( recursive ) {
System . err . println ( "Warning: recursive search of stdin!" );
}
prog . process ( new
new InputStreamReader ( System . in ), null
null );
} else
else {
iif (! dontPrintFileName )
dontPrintFileName = ix == argv . length - 1 ; // Nor if only one file.
iif ( recursive )
dontPrintFileName = false
false ;
// unless a directory!
for
for ( int
int i = ix ; i < argv . length ; i ++) { // note starting index
try
try {
prog . process ( new
new File ( argv [ i ]));
} catch
catch ( Exception e ) {
System . err . println ( e );
}
}
}
}
/** Construct a JGrep object.
* @param patt The pattern to look for
* @param args the command-line options.
*/
public
public JGrep ( String patt ) throws
throws PatternSyntaxException {
iif ( debug ) {
System . err . printf ( "JGrep.JGrep(%s)%n" , patt );
}
// compile the regular expression
int
int caseMode = ignoreCase ?
Pattern . UNICODE_CASE | Pattern . CASE_INSENSITIVE :
0 ;
pattern = Pattern . compile ( patt , caseMode );
matcher = pattern . matcher ( "" );
}
/** Process one command line argument (file or directory)
Search WWH ::




Custom Search