@Test public void shouldWriteByteArray() { final byte[] data = new byte[2]; final DirectBufferOutputStream outputStream = new DirectBufferOutputStream(new UnsafeBuffer(data)); final byte[] source = { 1, 2 }; outputStream.write(source); assertArrayEquals(source, data); }
public void write(final int b) { if (position == length) { throw new IllegalStateException("position has reached the end of underlying buffer"); } buffer.putByte(offset + position, (byte)b); ++position; }
DirectBufferOutputStream extends OutputStream { public void write(final int b) { if (position == length) { throw new IllegalStateException("position has reached the end of underlying buffer"); } buffer.putByte(offset + position, (byte)b); ++position; } }
DirectBufferOutputStream extends OutputStream { public void write(final int b) { if (position == length) { throw new IllegalStateException("position has reached the end of underlying buffer"); } buffer.putByte(offset + position, (byte)b); ++position; } DirectBufferOutputStream();  DirectBufferOutputStream(final MutableDirectBuffer buffer);  DirectBufferOutputStream(final MutableDirectBuffer buffer, final int offset, final int length); }
DirectBufferOutputStream extends OutputStream { public void write(final int b) { if (position == length) { throw new IllegalStateException("position has reached the end of underlying buffer"); } buffer.putByte(offset + position, (byte)b); ++position; } DirectBufferOutputStream();  DirectBufferOutputStream(final MutableDirectBuffer buffer);  DirectBufferOutputStream(final MutableDirectBuffer buffer, final int offset, final int length); void wrap(final MutableDirectBuffer buffer); void wrap(final MutableDirectBuffer buffer, final int offset, final int length); int position(); int offset(); MutableDirectBuffer buffer(); int length(); void write(final int b); void write(final byte[] srcBytes, final int srcOffset, final int length); void write(final byte[] srcBytes); void flush(); void close(); }
DirectBufferOutputStream extends OutputStream { public void write(final int b) { if (position == length) { throw new IllegalStateException("position has reached the end of underlying buffer"); } buffer.putByte(offset + position, (byte)b); ++position; } DirectBufferOutputStream();  DirectBufferOutputStream(final MutableDirectBuffer buffer);  DirectBufferOutputStream(final MutableDirectBuffer buffer, final int offset, final int length); void wrap(final MutableDirectBuffer buffer); void wrap(final MutableDirectBuffer buffer, final int offset, final int length); int position(); int offset(); MutableDirectBuffer buffer(); int length(); void write(final int b); void write(final byte[] srcBytes, final int srcOffset, final int length); void write(final byte[] srcBytes); void flush(); void close();  }