FileDocCategorySizeDatePackage
Grep0.javaAPI DocExample638Sat May 31 17:18:34 BST 2003None

Grep0

public class Grep0 extends Object
Grep0 - Match lines from stdin against the pattern on the command line.

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

		BufferedReader is =
			new BufferedReader(new InputStreamReader(System.in));
		if (args.length != 1) {
			System.err.println("Usage: MatchLines pattern");
			System.exit(1);
		}
		Pattern patt = Pattern.compile(args[0]);
		Matcher matcher = patt.matcher("");
		String line = null;
		while ((line = is.readLine()) != null) {
			matcher.reset(line);
			if (matcher.find()) {
				System.out.println("MATCH: " + line);
			}
		}