code: public static void writeStream(InputStream in, OutputStream out) throws IOException {
      int c;
      while ((c = in.read()) >= 0) {
        out.write((byte) c);
      }
    }
docs: Copies the contents of an <code>InputStream</code> to an
  <code>OutputStream</code>.
  @param in The <code>InputStream</code> to read from.
  @param out The <code>OutputStream</code> to write to.
  @throws IOException If unable to read from <code>in</code> or write to
  <code>out</code>.