public static void writeString(
      OutputStream outputStream,
      String str,
      String encoding,
      ThreadLocal<ByteBuffer> encodingBufferLocal)
      throws IOException {
    if (str != null) {
      byte[] strBuffer = str.getBytes(encoding);
      writeInt(outputStream, strBuffer.length, encodingBufferLocal);
      outputStream.write(strBuffer);
    } else {
      writeInt(outputStream, 0, encodingBufferLocal);
    }
  }
Write a string into the given stream.

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