public static String readString(
      DataInputStream inputStream, String encoding, ThreadLocal<byte[]> strBufferLocal, int length)
      throws IOException {
    byte[] strBuffer;
    if (length > 0) {
      if (strBufferLocal != null) {
        strBuffer = strBufferLocal.get();
        if (strBuffer == null || length > strBuffer.length) {
          strBuffer = new byte[length];
          strBufferLocal.set(strBuffer);
        }
      } else {
        strBuffer = new byte[length];
      }

      inputStream.read(strBuffer, 0, length);
      return new String(strBuffer, 0, length, encoding);
    }
    return null;
  }
Read a string from the given stream.

@param inputStream the source to read.
@param encoding string encoding like 'utf-8'.
@param strBufferLocal a ThreadLocal buffer may be passed to avoid frequently memory
    allocations. A null may also be passed to use a local buffer.
@return a string read from the stream.
@throws IOException when an exception raised during operating the stream.
iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/utils/IOUtils.java