@InterfaceAudience.Private public class ByteArrayOutputStream extends OutputStream implements ByteBufferWriter
Modifier and Type | Field and Description |
---|---|
private byte[] |
buf |
private static int |
MAX_ARRAY_SIZE |
private int |
pos |
Constructor and Description |
---|
ByteArrayOutputStream() |
ByteArrayOutputStream(int capacity) |
Modifier and Type | Method and Description |
---|---|
private void |
checkSizeAndGrow(int extra) |
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
private static final int MAX_ARRAY_SIZE
private byte[] buf
private int pos
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
private void checkSizeAndGrow(int extra)
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 The Apache Software Foundation. All rights reserved.