code: public void write(Reader reader, boolean escape, boolean noBackslashEscapes) throws IOException {
      char[] buffer = new char[4096];
      int len;
      while ((len = reader.read(buffer)) >= 0) {
        byte[] data = new String(buffer, 0, len).getBytes("UTF-8");
        if (escape) {
          writeBytesEscaped(data, data.length, noBackslashEscapes);
        } else {
          write(data);
        }
  
      }
    }
docs: Write reader into socket.
  
  @param reader             reader
  @param escape             must be escape
  @param noBackslashEscapes escape method
  @throws IOException if socket error occur