Package org.apache.hadoop.hbase.io
Class ByteArrayOutputStream
java.lang.Object
java.io.OutputStream
org.apache.hadoop.hbase.io.ByteArrayOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
,ByteBufferWriter
Our own implementation of ByteArrayOutputStream where all methods are NOT synchronized and
supports writing ByteBuffer directly to it.
-
Field Summary
Modifier and TypeFieldDescriptionprivate byte[]
private static final int
private int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
checkSizeAndGrow
(int extra) byte[]
Returns the underlying array where the data gets accumulatedvoid
reset()
Resets thepos
field of this byte array output stream to zero.int
size()
Returns The current size of the buffer.byte[]
Copies the content of this Stream into a new byte array.void
toByteBuff
(ByteBuff buff) void
write
(byte[] b, int off, int len) void
write
(int b) void
write
(ByteBuffer b, int off, int len) Writeslen
bytes from the specified ByteBuffer starting at offsetoff
void
writeInt
(int i) Writes anint
to the underlying output stream as four bytes, high byte first.Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write
-
Field Details
-
MAX_ARRAY_SIZE
- See Also:
-
buf
-
pos
-
-
Constructor Details
-
ByteArrayOutputStream
public ByteArrayOutputStream() -
ByteArrayOutputStream
-
-
Method Details
-
write
Description copied from interface:ByteBufferWriter
Writeslen
bytes from the specified ByteBuffer starting at offsetoff
- Specified by:
write
in interfaceByteBufferWriter
- Parameters:
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.
-
writeInt
Description copied from interface:ByteBufferWriter
Writes anint
to the underlying output stream as four bytes, high byte first.- Specified by:
writeInt
in interfaceByteBufferWriter
- Parameters:
i
- theint
to write
-
write
- Specified by:
write
in classOutputStream
-
write
- Overrides:
write
in classOutputStream
-
checkSizeAndGrow
-
reset
Resets thepos
field of this byte array output stream to zero. The output stream can be used again. -
toByteArray
Copies the content of this Stream into a new byte array.- Returns:
- the contents of this output stream, as new byte array.
-
toByteBuff
-
getBuffer
Returns the underlying array where the data gets accumulated -
size
Returns The current size of the buffer.
-