@HashCodeAndEqualsPlugin.Enhance public class StreamDrainer extends java.lang.Object
InputStream into a byte array.| Modifier and Type | Field and Description |
|---|---|
private int |
bufferSize
The buffer size for reading from a given stream.
|
static StreamDrainer |
DEFAULT
A default instance using the
DEFAULT_BUFFER_SIZE. |
static int |
DEFAULT_BUFFER_SIZE
The default size of the buffer for draining a stream.
|
private static int |
END_OF_STREAM
A convenience constant referring to the value representing the end of a stream.
|
private static int |
FROM_BEGINNING
A convenience constant referring to the value representing the start of a stream.
|
| Constructor and Description |
|---|
StreamDrainer()
Creates a stream drainer with the default buffer size.
|
StreamDrainer(int bufferSize)
Creates a stream drainer with the given buffer size.
|
| Modifier and Type | Method and Description |
|---|---|
byte[] |
drain(java.io.InputStream inputStream)
Drains an input stream into a byte array.
|
public static final int DEFAULT_BUFFER_SIZE
public static final StreamDrainer DEFAULT
DEFAULT_BUFFER_SIZE.private static final int END_OF_STREAM
private static final int FROM_BEGINNING
private final int bufferSize
public StreamDrainer()
public StreamDrainer(int bufferSize)
bufferSize - The buffer size for reading from a given stream.public byte[] drain(java.io.InputStream inputStream)
throws java.io.IOException
inputStream - The input stream to drain.java.io.IOException - If the stream reading causes an error.