public static void copyStreams(InputStream in,OutputStream out) throws IOException {
  if (in == null || out == null) {
    throw new IllegalArgumentException();
  }
  final byte[] buffer=new byte[4096];
  int len;
  while (-1 != (len=in.read(buffer,0,buffer.length))) {
    out.write(buffer,0,len);
  }
}

public static void copyStreams ( InputStream in , OutputStream out ) throws IOException { if ( in == null || out == null ) { throw new IllegalArgumentException ( ) ; } final byte [ ] buffer = new byte [ 4096 ] ; int len ; while ( - 1 != ( len = in . read ( buffer , 0 , buffer . length ) ) ) { out . write ( buffer , 0 , len ) ; } }
copy all data from in to out in 4096 byte chunks .
