org.apache.cassandra.io.util

## Class DataOutputBuffer

- java.lang.Object
- - java.io.OutputStream
  - - java.io.FilterOutputStream
    - - java.io.DataOutputStream
      - - org.apache.cassandra.io.util.DataOutputBuffer

All Implemented Interfaces:
  java.io.Closeable, java.io.DataOutput, java.io.Flushable, java.lang.AutoCloseable

    public final class DataOutputBuffer
    extends java.io.DataOutputStream

An implementation of the DataOutputStream interface using a FastByteArrayOutputStream and exposing its buffer so copies can be avoided. This class is completely thread unsafe.

### Field Summary

### Fields inherited from class java.io.DataOutputStream

`written`

### Fields inherited from class java.io.FilterOutputStream

`out`

### Constructor Summary

Constructors
Constructor and Description
`DataOutputBuffer()`
`DataOutputBuffer(int size)`

### Method Summary

Methods
`byte[]` `getData()` Returns the current contents of the buffer.
`int` `getLength()` Returns the length of the valid data currently in the buffer.
`void` `write(byte[] b, int off, int len)`
`void` `write(int b)`

### Methods inherited from class java.io.DataOutputStream

`flush, size, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF`

### Methods inherited from class java.io.FilterOutputStream

`close, write`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface java.io.DataOutput

`write`

### Constructor Detail

#### DataOutputBuffer

    public DataOutputBuffer()

#### DataOutputBuffer

    public DataOutputBuffer(int size)

### Method Detail

#### write

    public void write(int b)

Specified by:
  `write` in interface `java.io.DataOutput`
Overrides:
  `write` in class `java.io.DataOutputStream`

#### write

    public void write(byte[] b,
             int off,
             int len)

Specified by:
  `write` in interface `java.io.DataOutput`
Overrides:
  `write` in class `java.io.DataOutputStream`

#### getData

    public byte[] getData()

Returns the current contents of the buffer. Data is only valid to `getLength()`.

#### getLength

    public int getLength()

Returns the length of the valid data currently in the buffer.