Package com.google.gerrit.server.ioutil
Class LimitedByteArrayOutputStream
java.lang.Object
java.io.OutputStream
com.google.gerrit.server.ioutil.LimitedByteArrayOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
A stream that throws an exception if it consumes data beyond a configured byte count.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
-
Constructor Summary
ConstructorsConstructorDescriptionLimitedByteArrayOutputStream
(int max, int initial) Constructs a LimitedByteArrayOutputStream, which stores output in memory up to a certain specified size. -
Method Summary
Methods inherited from class java.io.OutputStream
close, flush, nullOutputStream, write
-
Constructor Details
-
LimitedByteArrayOutputStream
public LimitedByteArrayOutputStream(int max, int initial) Constructs a LimitedByteArrayOutputStream, which stores output in memory up to a certain specified size. When the output exceeds the specified size a LimitExceededException is thrown.- Parameters:
max
- the maximum size in bytes which may be stored.initial
- the initial size. It must be smaller than the max size.
-
-
Method Details
-
write
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classOutputStream
- Throws:
IOException
-
toByteArray
public byte[] toByteArray()Returns a newly allocated byte array with contents of the buffer.
-