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
FieldsModifier and TypeFieldDescriptionprivate byte[]private static final intprivate int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcheckSizeAndGrow(int extra) byte[]Returns the underlying array where the data gets accumulatedvoidreset()Resets theposfield of this byte array output stream to zero.intsize()Returns The current size of the buffer.byte[]Copies the content of this Stream into a new byte array.voidtoByteBuff(ByteBuff buff) voidwrite(byte[] b, int off, int len) voidwrite(int b) voidwrite(ByteBuffer b, int off, int len) Writeslenbytes from the specified ByteBuffer starting at offsetoffvoidwriteInt(int i) Writes anintto 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:ByteBufferWriterWriteslenbytes from the specified ByteBuffer starting at offsetoff- Specified by:
writein interfaceByteBufferWriter- Parameters:
b- the data.off- the start offset in the data.len- the number of bytes to write.
-
writeInt
Description copied from interface:ByteBufferWriterWrites anintto the underlying output stream as four bytes, high byte first.- Specified by:
writeIntin interfaceByteBufferWriter- Parameters:
i- theintto write
-
write
- Specified by:
writein classOutputStream
-
write
- Overrides:
writein classOutputStream
-
checkSizeAndGrow
-
reset
Resets theposfield 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.
-