This saves memory over creating a new byte[] and ByteArrayOutputStream each time data is written.
Typical usage is something like the following:
WritableByteArray buffer = new WritableByteArray(); while (... loop condition ...) { buffer.reset(); ... write to buffer ... byte[] data = buffer.getData(); int dataLength = buffer.getLength(); ... write data to its ultimate destination ... }
|
|
|
|
|
|
|
|
|
|