public class LimitedByteArrayOutputStream
extends java.io.OutputStream
| Constructor and Description |
|---|
LimitedByteArrayOutputStream(int bufferSize)
Create a buffering output stream with the given size limit.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
long |
getTotalNumberOfBytes()
Get the total number of bytes written to this stream.
|
void |
reset()
Clear all cached bytes.
|
byte[] |
toByteArray()
Get the cached bytes.
|
java.lang.String |
toString()
Get a string representation.
|
java.lang.String |
toString(java.nio.charset.Charset charset)
Get the content of this buffer as a string.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
public LimitedByteArrayOutputStream(int bufferSize)
bufferSize - maximum number of buffered bytespublic void write(int b)
throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(@NotNull byte[] b) throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void write(@NotNull byte[] b, int off, int len) throws java.io.IOException
write in class java.io.OutputStreamjava.io.IOExceptionpublic void flush()
throws java.io.IOException
flush in interface java.io.Flushableflush in class java.io.OutputStreamjava.io.IOExceptionpublic void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.OutputStreamjava.io.IOException@NotNull public byte[] toByteArray()
public void reset()
total number of bytes.public long getTotalNumberOfBytes()
@NotNull public java.lang.String toString(@NotNull java.nio.charset.Charset charset)
charset - charset used to decode the cached bytes@NotNull public java.lang.String toString()
ByteArrayOutputStream
which uses toString(Charset) which is not
always a good idea.toString in class java.lang.Object