import java.io.*; // invoke 4 different ways: // 1. java TestPart3 10 10 < p5.html > testPart3.out1 // 2. java TestPart3 100 100 < TestPart3.java > testPart3.out2 // 3. java TestPart3 10 100 < p5.html > testPart3.out3 // 4. java TestPart3 100 10 < TestPart3.java > testPart3.out4 // for all cases, the output file should be identical to the input file - // check with diff or cmp public class TestPart3 { static public void main(String args[]) { final InputStreamReader in1 = new InputStreamReader(System.in); final PrintWriter out2 = new PrintWriter(System.out, true ); PipedReader in2 = new PipedReader(); PipedWriter out1 = new PipedWriter(); try { out1.connect(in2); } catch (IOException e) { System.out.println(e); } if (args.length != 2) throw new IllegalArgumentException("TestPart3 requires 2 arguments: Filter1BufferSize Filter2BufferSize"); // try with different buffer sizes int Filter1BufSize = Integer.parseInt(args[0]); int Filter2BufSize = Integer.parseInt(args[1]); Runnable compute1 = new PassThrough(); Filter filter1 = new FilterImpl(in1, out1, Filter1BufSize, Filter1BufSize, compute1); ( (PassThrough) compute1).setFilter(filter1); Runnable compute2 = new PassThrough(); Filter filter2 = new FilterImpl(in2, out2, Filter2BufSize, Filter2BufSize, compute2); ( (PassThrough) compute2).setFilter(filter2); filter1.startFilter(); filter2.startFilter(); } }