// the behavior file for forwarding streams StreamFunnel{ {{ StreamFunnel( InputStream i1, InputStream i2, OutputStream o) { s1 = new StreamConnector(i1, o); s2 = new StreamConnector(i2, o); } public void run() { s1.start(); s2.start(); try { //System.out.println("Waiting for s1.."); s1.join(); //System.out.println("Waiting for s2.."); s2.join(); } catch (Exception e) { System.out.println(e); e.printStackTrace(System.out); } } }} } StreamConnector { {{ synchronized protected void write(byte b) throws IOException { target.write(b); } public void run() { try { int read = src.read(); while (read > 0) { write((byte) read); read = src.read(); } } catch (Exception e) { System.out.println(e); e.printStackTrace(System.out); } } }} }