newDataOutput

Returns a new ByteArrayDataOutput instance which writes to the
given ByteArrayOutputStream. The given output stream is not reset
before being written to by the returned ByteArrayDataOutput and
new data will be appended to any existing content.

Note that if the given output stream was not empty or is modified after
the ByteArrayDataOutput is created, the contract for
ByteArrayDataOutput.toByteArray() will not be honored (the bytes
returned in the byte array may not be exactly what was written via calls to
ByteArrayDataOutput).

read

Reads some bytes from an input stream and stores them into the buffer array
b. This method blocks until len bytes of input data have
been read into the array, or end of file is detected. The number of bytes
read is returned, possibly zero. Does not close the stream.

A caller can detect EOF if the number of bytes read is less than
len. All subsequent calls on the same stream will return zero.

If b is null, a NullPointerException is thrown. If
off is negative, or len is negative, or off+len is
greater than the length of the array b, then an
IndexOutOfBoundsException is thrown. If len is zero, then
no bytes are read. Otherwise, the first byte read is stored into element
b[off], the next one into b[off+1], and so on. The number
of bytes read is, at most, equal to len.