GrepReader.javaAPI DocExample1875Mon Sep 22 13:30:32 BST 1997None


public class GrepReader extends BufferedReader
This class is a BufferedReader that filters out all lines that do not contain the specified pattern.

Fields Summary
Constructors Summary
public GrepReader(Reader in, String pattern)
Pass the stream to our superclass, and remember the pattern ourself

    this.pattern = pattern;
Methods Summary
public final java.lang.StringreadLine()
This is the filter: call our superclass's readLine() to get the actual lines, but only return lines that contain the pattern. When the superclass readLine() returns null (EOF), we return null.

    String line;
    do { line = super.readLine(); }
    while ((line != null) && line.indexOf(pattern) == -1);
    return line;