// copy input to output import java.io.*; public class IOcopy extends Thread { private BufferedInputStream in; private BufferedOutputStream out; public IOcopy( BufferedInputStream in, BufferedOutputStream out) { this.in = in; this.out = out; } public void run() { int n; byte buf[] = new byte[2048]; try { while( (n = in.read( buf)) > 0) { out.write( buf, 0, n); out.flush(); } out.write( "\nDone.\n".getBytes()); out.flush(); } catch (Exception ex) { synchronized( System.out) { ex.printStackTrace( System.out); System.out.flush(); } } } }