Package net.bytebuddy.utility
Class StreamDrainer
- java.lang.Object
-
- net.bytebuddy.utility.StreamDrainer
-
@Enhance public class StreamDrainer extends java.lang.Object
A utility for draining the contents of anInputStream
into abyte
array.
-
-
Field Summary
Fields Modifier and Type Field Description private int
bufferSize
The buffer size for reading from a given stream.static StreamDrainer
DEFAULT
A default instance using theDEFAULT_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 Summary
Constructors Constructor Description StreamDrainer()
Creates a stream drainer with the default buffer size.StreamDrainer(int bufferSize)
Creates a stream drainer with the given buffer size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
drain(java.io.InputStream inputStream)
Drains an input stream into a byte array.
-
-
-
Field Detail
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE
The default size of the buffer for draining a stream.- See Also:
- Constant Field Values
-
DEFAULT
public static final StreamDrainer DEFAULT
A default instance using theDEFAULT_BUFFER_SIZE
.
-
END_OF_STREAM
private static final int END_OF_STREAM
A convenience constant referring to the value representing the end of a stream.- See Also:
- Constant Field Values
-
FROM_BEGINNING
private static final int FROM_BEGINNING
A convenience constant referring to the value representing the start of a stream.- See Also:
- Constant Field Values
-
bufferSize
private final int bufferSize
The buffer size for reading from a given stream.
-
-
Method Detail
-
drain
public byte[] drain(java.io.InputStream inputStream) throws java.io.IOException
Drains an input stream into a byte array. The given input stream is not closed.- Parameters:
inputStream
- The input stream to drain.- Returns:
- A byte array containing the content of the input stream.
- Throws:
java.io.IOException
- If the stream reading causes an error.
-
-