public void write(DataInput in, int len) throws IOException {
            int newcount = count + len;
            if (newcount > buf.length) {
                byte[] newbuf = new byte[Math.max(buf.length << 1, newcount)];
                System.arraycopy(buf, 0, newbuf, 0, count);
                buf = newbuf;
            }
            in.readFully(buf, count, len);
            count = newcount;
        }
A reusable {@link java.io.DataOutput} implementation that writes to an in-memory buffer.

This saves memory over creating a new DataOutputStream and
ByteArrayOutputStream each time data is written.

Typical usage is something like the following:

DataOutputBuffer buffer = new DataOutputBuffer();
while (... loop condition ...) {
  buffer.reset();
  ... write buffer using DataOutput methods ...
  byte[] data = buffer.getData();
  int dataLength = buffer.getLength();
  ... write data to its ultimate destination ...
}
inlong-common/src/main/java/org/apache/inlong/common/msg/DataOutputBuffer.java