code: public int readUTF8ByByteLength(char []buffer, int offset, int byteLength)
      throws IOException
    {
      int k = 0;
      for (int i = 0; i < byteLength; i++) {
        if (_readLength <= _readOffset) {
          readBuffer();
        }
  
        int ch = _readBuffer[_readOffset++] & 0xff;
  
        if (ch < 0x80) {
          buffer[k++] = (char) ch;
        }
        else if ((ch & 0xe0) == 0xc0) {
          int c2 = read();
          i += 1;
          buffer[k++] = (char) (((ch & 0x1f) << 6) + (c2 & 0x3f));
        }
        else {
          int c2 = read();
          int c3 = read();
  
          i += 2;
          buffer[k++] = (char) (((ch & 0x1f) << 12)
                                + ((c2 & 0x3f) << 6)
                                + ((c3 & 0x3f)));
        }
      }
  
      return k;
    }
docs: Reads a utf-8 string