public static void writeInt(
      OutputStream outputStream, int i, ThreadLocal<ByteBuffer> encodingBufferLocal)
      throws IOException {
    ByteBuffer encodingBuffer;
    if (encodingBufferLocal != null) {
      encodingBuffer = encodingBufferLocal.get();
      if (encodingBuffer == null) {
        // set to 8 because this buffer may be applied to other types
        encodingBuffer = ByteBuffer.allocate(8);
        encodingBufferLocal.set(encodingBuffer);
      }
    } else {
      encodingBuffer = ByteBuffer.allocate(4);
    }
    encodingBuffer.clear();
    encodingBuffer.putInt(i);
    outputStream.write(encodingBuffer.array(), 0, Integer.BYTES);
  }
Write an integer into the given stream.

@param outputStream the destination to insert.
@param i the integer to be written.
@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