public class DiscardingByteArrayOutputStream extends OutputStream
| Modifier and Type | Field and Description |
|---|---|
protected byte[] |
buf
The buffer where data is stored.
|
protected int |
count
The number of valid bytes in the buffer.
|
protected long |
startOffset |
| Constructor and Description |
|---|
DiscardingByteArrayOutputStream()
Creates a new byte array output stream.
|
DiscardingByteArrayOutputStream(int size)
Creates a new byte array output stream, with a buffer capacity of
the specified size, in bytes.
|
| Modifier and Type | Method and Description |
|---|---|
long |
available()
Returns the last index that is available.
|
void |
close()
Closing a ByteArrayOutputStream has no effect.
|
void |
discardTo(long n) |
byte[] |
get(long start,
int count) |
void |
reset()
Resets the
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. |
int |
size()
Returns the current size of the buffer.
|
byte[] |
toByteArray()
Creates a newly allocated byte array.
|
String |
toString()
Converts the buffer's contents into a string decoding bytes using the
platform's default character set.
|
void |
write(byte[] b,
int off,
int len)
Writes
len bytes from the specified byte array
starting at offset off to this byte array output stream. |
void |
write(int b)
Writes the specified byte to this byte array output stream.
|
flush, writeprotected byte[] buf
protected int count
protected long startOffset
public DiscardingByteArrayOutputStream()
public DiscardingByteArrayOutputStream(int size)
size - the initial size.IllegalArgumentException - if size is negative.public byte[] get(long start,
int count)
public void write(int b)
write in class OutputStreamb - the byte to be written.public void write(byte[] b,
int off,
int len)
len bytes from the specified byte array
starting at offset off to this byte array output stream.write in class OutputStreamb - the data.off - the start offset in the data.len - the number of bytes to write.public void reset()
count field of this byte array output
stream to zero, so that all currently accumulated output in the
output stream is discarded. The output stream can be used again,
reusing the already allocated buffer space.ByteArrayInputStream.countpublic byte[] toByteArray()
ByteArrayOutputStream.size()public int size()
count field, which is the number
of valid bytes in this output stream.ByteArrayOutputStream.countpublic String toString()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionpublic long available()
public void discardTo(long n)
Copyright © 2018. All rights reserved.