@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, writeprivate 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)
ByteBufferWriterlen bytes from the specified ByteBuffer starting at offset offwrite in interface ByteBufferWriterb - the data.off - the start offset in the data.len - the number of bytes to write.public void writeInt(int i)
ByteBufferWriterint to the underlying output stream as four bytes, high byte first.writeInt in interface ByteBufferWriteri - the int to writepublic void write(int b)
write in class OutputStreampublic void write(byte[] b, int off, int len)
write in class OutputStreamprivate 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.