code: private void write(final DataInputStream stream, final Writer outputWriter, final int numberOfBytes)
        throws IOException {
      final byte[] buf = new byte[65535];
      int lenRemaining = numberOfBytes;
      while (lenRemaining > 0) {
        final int len = stream.read(buf, 0, lenRemaining > 65535 ? 65535 : lenRemaining);
        if (len > 0) {
          outputWriter.write(new String(buf, 0, len, "UTF-8"));
          lenRemaining -= len;
        } else {
          break;
        }
      }
    }
docs: Writes the next numberOfBytes bytes from the stream to the outputWriter, assuming that the bytes are UTF-8 encoded
  characters.
  
  @param stream
  @param outputWriter
  @param numberOfBytes
  @throws IOException