Package org.agrona.io
Class ExpandableDirectBufferOutputStream
java.lang.Object
java.io.OutputStream
org.agrona.io.ExpandableDirectBufferOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
OutputStream that wraps an underlying expandable version of a MutableDirectBuffer.-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.Wrap givenMutableDirectBuffer.ExpandableDirectBufferOutputStream(MutableDirectBuffer buffer, int offset) Wrap givenMutableDirectBufferat a given offset. -
Method Summary
Modifier and TypeMethodDescriptionbuffer()The underlying buffer being wrapped.voidclose()intoffset()The offset within the underlying buffer at which to start.intposition()The position in the buffer from the offset up to which has been written.voidwrap(MutableDirectBuffer buffer) Wrap a given buffer beginning with an offset of 0.voidwrap(MutableDirectBuffer buffer, int offset) Wrap a given buffer beginning at an offset.voidwrite(byte[] srcBytes, int srcOffset, int length) Write a byte[] to the buffer.voidwrite(int b) Write a byte to buffer.Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
Constructor Details
-
ExpandableDirectBufferOutputStream
public ExpandableDirectBufferOutputStream()Default constructor. -
ExpandableDirectBufferOutputStream
Wrap givenMutableDirectBuffer.- Parameters:
buffer- to wrap.
-
ExpandableDirectBufferOutputStream
Wrap givenMutableDirectBufferat a given offset.- Parameters:
buffer- to wrap.offset- at which the puts will occur.
-
-
Method Details
-
wrap
Wrap a given buffer beginning with an offset of 0.- Parameters:
buffer- to wrap
-
wrap
Wrap a given buffer beginning at an offset.- Parameters:
buffer- to wrapoffset- at which the puts will occur.
-
position
public int position()The position in the buffer from the offset up to which has been written.- Returns:
- the position in the buffer from the offset up to which has been written.
-
offset
public int offset()The offset within the underlying buffer at which to start.- Returns:
- offset within the underlying buffer at which to start.
-
buffer
The underlying buffer being wrapped.- Returns:
- the underlying buffer being wrapped.
-
write
public void write(int b) Write a byte to buffer.- Specified by:
writein classOutputStream- Parameters:
b- to be written.
-
write
public void write(byte[] srcBytes, int srcOffset, int length) Write a byte[] to the buffer.- Overrides:
writein classOutputStream- Parameters:
srcBytes- to writesrcOffset- at which to begin reading bytes from the srcBytes.length- of the srcBytes to read.
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream
-