public class DoubleBufferedInputStream<I extends java.io.InputStream>
extends java.io.InputStream
InputStream that double-buffers data from an underlying input stream.
Upon reaching the end of the underlying data stream, the underlying data stream is
automatically closed.
Any exceptions while reading from the underlying input stream cause the DoubleBufferedInputStream
to withhold pending data.
This is done in order to minimize the risk of emitting unauthenticated plaintext, while at the same
time being somewhat resource-efficient.
The minimum number of bytes to withhold can be configured (BUFFER_SIZE by default).| Constructor and Description |
|---|
DoubleBufferedInputStream(I in)
Create a
DoubleBufferedInputStream, which buffers twice 32MiB. |
DoubleBufferedInputStream(I in,
int bufferSize)
Create a
DoubleBufferedInputStream, which buffers twice the given buffer size in bytes. |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
I |
getInputStream()
Return the underlying
InputStream. |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
public DoubleBufferedInputStream(I in)
DoubleBufferedInputStream, which buffers twice 32MiB.in - input streampublic DoubleBufferedInputStream(I in, int bufferSize)
DoubleBufferedInputStream, which buffers twice the given buffer size in bytes.in - input streambufferSize - buffer sizepublic I getInputStream()
InputStream.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class java.io.InputStreamjava.io.IOExceptionpublic int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException