Package net.bytebuddy.utility
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 TypeFieldDescriptionprivate final intThe buffer size for reading from a given stream.static final StreamDrainerA default instance using theDEFAULT_BUFFER_SIZE.static final intThe default size of the buffer for draining a stream.private static final intA convenience constant referring to the value representing the end of a stream.private static final intA convenience constant referring to the value representing the start of 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. -
END_OF_STREAM
private static final int END_OF_STREAMA convenience constant referring to the value representing the end of a stream.- See Also:
-
FROM_BEGINNING
private static final int FROM_BEGINNINGA convenience constant referring to the value representing the start of a stream.- See Also:
-
bufferSize
private final int bufferSizeThe buffer size for reading from a given stream.
-
-
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.
-