private static long copy(InputStream source,OutputStream sink) throws IOException {
  long nread=0L;
  byte[] buf=new byte[BUFFER_SIZE];
  int n;
  while ((n=source.read(buf)) > 0) {
    sink.write(buf,0,n);
    nread+=n;
  }
  return nread;
}

private static long copy ( InputStream source , OutputStream sink ) throws IOException { long nread = 0L ; byte [ ] buf = new byte [ BUFFER_SIZE ] ; int n ; while ( ( n = source . read ( buf ) ) > 0 ) { sink . write ( buf , 0 , n ) ; nread += n ; } return nread ; }
reads all bytes from an input stream and writes them to an output stream .
