public class FastByteArrayOutputStream extends OutputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buffer |
protected int |
delta |
protected int |
size |
| Constructor and Description |
|---|
FastByteArrayOutputStream()
Construct a new FastByteArrayOutputStream with a logical size of 0,
but an initial capacity of 1K (1024 bytes).
|
FastByteArrayOutputStream(int capacity)
Construct a new FastByteArrayOutputStream with the passed in capacity, and a
default delta (1024).
|
FastByteArrayOutputStream(int capacity,
int delta)
Construct a new FastByteArrayOutputStream with a logical size of 0,
but an initial capacity of 'capacity'.
|
| Modifier and Type | Method and Description |
|---|---|
void |
clear()
Reset the stream so it can be used again.
|
byte[] |
getBuffer() |
int |
size()
The logical size of the byte[] this stream represents, not
its physical size, which could be larger.
|
String |
toString() |
void |
write(byte[] bytes,
int offset,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream.
|
void |
writeTo(byte[] dest)
Copy the internal byte[] to the passed in byte[].
|
void |
writeTo(OutputStream out)
Convenience method to copy the contained byte[] to the passed in OutputStream.
|
close, flush, writepublic FastByteArrayOutputStream()
public FastByteArrayOutputStream(int capacity)
capacity - public FastByteArrayOutputStream(int capacity,
int delta)
capacity - int capacity (internal buffer size), must be > 0delta - int delta, size to increase the internal buffer by when limit reached. If the value
is negative, then the internal buffer is doubled in size when additional capacity is needed.public byte[] getBuffer()
public void write(int b)
write in class OutputStreamb - the byte to be written.public void write(byte[] bytes,
int offset,
int len)
len bytes from the specified byte array
starting at offset off to this stream.write in class OutputStreambytes - byte[] the data to write to this stream.offset - the start offset in the data.len - the number of bytes to write.public void writeTo(OutputStream out) throws IOException
out - OutputStream targetIOExceptionpublic void writeTo(byte[] dest)
dest - byte[] targetpublic String toString()
public void clear()
public int size()
Copyright © 2017. All rights reserved.