@InterfaceAudience.Private public class ByteArrayOutputStream extends OutputStream implements ByteBufferWriter
Constructor and Description |
---|
ByteArrayOutputStream() |
ByteArrayOutputStream(int capacity) |
Modifier and Type | Method and Description |
---|---|
byte[] |
getBuffer() |
void |
reset()
Resets the
pos field of this byte array output stream to zero. |
int |
size() |
byte[] |
toByteArray()
Copies the content of this Stream into a new byte array.
|
void |
write(byte[] b,
int off,
int len) |
void |
write(ByteBuffer b,
int off,
int len)
Writes
len bytes from the specified ByteBuffer starting at offset off |
void |
write(int b) |
void |
writeInt(int i)
Writes an
int to the underlying output stream as four bytes, high byte first. |
close, flush, write
public ByteArrayOutputStream()
public ByteArrayOutputStream(int capacity)
public void write(ByteBuffer b, int off, int len)
ByteBufferWriter
len
bytes from the specified ByteBuffer starting at offset off
write
in interface ByteBufferWriter
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.public void writeInt(int i)
ByteBufferWriter
int
to the underlying output stream as four bytes, high byte first.writeInt
in interface ByteBufferWriter
i
- the int
to writepublic void write(int b)
write
in class OutputStream
public void write(byte[] b, int off, int len)
write
in class OutputStream
public void reset()
pos
field of this byte array output stream to zero. The output stream
can be used again.public byte[] toByteArray()
public byte[] getBuffer()
public int size()
Copyright © 2007–2019 Cloudera. All rights reserved.