public static void copy(InputStream in, OutputStream out) throws IOException {

    byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

    for (int length = in.read(buffer); length > 0; length = in.read(buffer)) {
      out.write(buffer, 0, length);
      out.flush();
    }
  }
public static void copy ( InputStream in , OutputStream out ) throws IOException { byte [ ] buffer = new byte [ DEFAULT_BUFFER_SIZE ] ; for ( int length = in . read ( buffer ) ; length > 0 ; length = in . read ( buffer ) ) { out . write ( buffer , 0 , length ) ; out . flush ( ) ; } }
Copies the contents of the source {@link InputStream} to the target {@link OutputStream}.

@param in the source {@link InputStream} to copy bytes from.
@param out the target {@link OutputStream} to copy bytes to.
@throws IOException if the copy operation results in an I/O error.
@see java.io.InputStream
@see java.io.OutputStream