Class StreamDrainer
java.lang.Object
net.bytebuddy.utility.StreamDrainer
A utility for draining the contents of an
InputStream into a byte array.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StreamDrainerA default instance using theDEFAULT_BUFFER_SIZE.static final intThe default size of the buffer for draining a stream. -
Constructor Summary
ConstructorsConstructorDescriptionCreates a stream drainer with the default buffer size.StreamDrainer(int bufferSize) Creates a stream drainer with the given buffer size. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]drain(InputStream inputStream) Drains an input stream into a byte array.
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZEThe default size of the buffer for draining a stream.- See Also:
-
DEFAULT
A default instance using theDEFAULT_BUFFER_SIZE.
-
-
Constructor Details
-
StreamDrainer
public StreamDrainer()Creates a stream drainer with the default buffer size. -
StreamDrainer
public StreamDrainer(int bufferSize) Creates a stream drainer with the given buffer size.- Parameters:
bufferSize- The buffer size for reading from a given stream.
-
-
Method Details
-
drain
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:
IOException- If the stream reading causes an error.
-