import java.io.*; import java.util.*; public class Text { static public void main(String args[]) { InputStreamReader in1 = new InputStreamReader(System.in); OutputStreamWriter out2 = new OutputStreamWriter(System.out); PipedReader in2 = new PipedReader(); PipedWriter out1 = new PipedWriter(); try { out1.connect(in2); } catch (IOException e) { System.out.println(e); } int initReadBufSize = 100; int initWriteBufSize = 100; // put entries into the map here - input/output character pairs char[][] ttable = { {'t', 'x'}, {'h', 'y'}, {'e', 'z'} }; // Translate is the class that implements the translation Translate t1 = new Translate(ttable); FilterImpl translate = new FilterImpl(in1, out1, initReadBufSize, initWriteBufSize, t1); // give the computation thread a hook back into the Filter t1.setFilter(translate); // pass in the string to match on the command line String match = args[0]; // StringMatch is the class that implements the string matching StringMatch s1 = new StringMatch(match); FilterImpl stringMatcher = new FilterImpl(in2, out2, initReadBufSize, initWriteBufSize, s1); // give the computation thread a hook back into the Filter s1.setFilter(stringMatcher); translate.startFilter(); stringMatcher.startFilter(); } }