code: public static void writeStreamToStream(InputStream input, OutputStream output)
    throws IOException {
      byte[] buffer = new byte[4096];
      while (true) {
        int len = input.read(buffer);
        if (len == -1) {
          break;
        }
        output.write(buffer, 0, len);
      }
    }
docs: Send all bytes from the input stream to the output stream.
  
  @param input
  The input bytes.
  @param output
  Where the bytes should be written.