public static int copy(InputStream in,OutputStream out,int bufSize) throws IOException {
  byte[] buf=new byte[bufSize];
  int cnt=0;
  for (int n; (n=in.read(buf)) > 0; ) {
    out.write(buf,0,n);
    cnt+=n;
  }
  return cnt;
}

public static int copy ( InputStream in , OutputStream out , int bufSize ) throws IOException { byte [ ] buf = new byte [ bufSize ] ; int cnt = 0 ; for ( int n ; ( n = in . read ( buf ) ) > 0 ; ) { out . write ( buf , 0 , n ) ; cnt += n ; } return cnt ; }
copies input byte stream to output byte stream .
