Package org.apache.druid.io
Class LimitedOutputStream
java.lang.Object
java.io.OutputStream
org.apache.druid.io.LimitedOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
An
OutputStream that limits how many bytes can be written. Throws IOException if the limit
is exceeded. *Not* thread-safe.-
Constructor Summary
ConstructorsConstructorDescriptionLimitedOutputStream(OutputStream out, long limit, Function<Long, String> exceptionMessageFn) Create a bytes-limited output stream. -
Method Summary
Methods inherited from class java.io.OutputStream
nullOutputStream
-
Constructor Details
-
LimitedOutputStream
Create a bytes-limited output stream.- Parameters:
out- output stream to wraplimit- bytes limitexceptionMessageFn- function for generating an exception message for anIOException, given the limit.
-
-
Method Details
-
write
- Specified by:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
write
- Overrides:
writein classOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
toByteArray
public byte[] toByteArray()
-