import java.io.*; public class Main { public static void main(String [] args) { Reader r = new InputStreamReader(System.in); LineNumberReader lnr = new LineNumberReader(r); r = lnr; // For each pattern specified on the command line, // create a StringPatternFilter instance for that // pattern and link it into a chain. // When finished we have something that looks like: // +---+ +---+ +---+ // r --|-o |--|-o |-...-|-o |--o System.in // +---+ +---+ +---+ // connecting r all the way back to the original // input stream. Each stage attempts to match one // of the patterns specified on the command line. for (int i = 0; i < args.length; i++) { r = new StringPatternFilter(r, args[i]); } // Create a PrintWriter to write to. Writer w = new PrintWriter(System.out); try { int c; // Read a character, write a character... while ((c = r.read()) > -1) { w.write(c); w.flush(); } } catch (EndOfStream eos) { // We got end of stream! } catch (JunkMailException jme) { // We got junk mail! System.err.println("Line " + (lnr.getLineNumber() + 1) + ": " + jme); System.exit(1); } catch (IOException ioe) { ioe.printStackTrace(System.err); } } }