public static void copy(InputStream in,OutputStream out) throws IOException {
synchronized (in) {
synchronized (out) {
      byte[] buffer=new byte[256];
      while (true) {
        int bytesRead=in.read(buffer);
        if (bytesRead == -1)         break;
        out.write(buffer,0,bytesRead);
      }
    }
  }
}

public static void copy ( InputStream in , OutputStream out ) throws IOException { synchronized ( in ) { synchronized ( out ) { byte [ ] buffer = new byte [ 256 ] ; while ( true ) { int bytesRead = in . read ( buffer ) ; if ( bytesRead == - 1 ) break ; out . write ( buffer , 0 , bytesRead ) ; } } } }
copy method from from e . r . harold ' s book " java i / o "
