public static long copy(InputStream input,OutputStream output,byte[] buffer) throws IOException {
  long count=0;
  int n=0;
  while (-1 != (n=input.read(buffer))) {
    output.write(buffer,0,n);
    count+=n;
  }
  return count;
}

public static long copy ( InputStream input , OutputStream output , byte [ ] buffer ) throws IOException { long count = 0 ; int n = 0 ; while ( - 1 != ( n = input . read ( buffer ) ) ) { output . write ( buffer , 0 , n ) ; count += n ; } return count ; }
copy an input stream to an output stream using the buffer .
