public final class StreamUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static java.io.InputStream |
convertBytesToStream(byte[] data)
Converts the byte array to an input stream.
|
static java.io.InputStream |
convertBytesToStream(byte[] data,
java.util.concurrent.ThreadPoolExecutor pool)
Converts the byte array to an input stream.
|
static byte[] |
read(java.io.InputStream inputStream,
int length)
Reads exactly length bytes from the stream.
|
static byte[] |
readFully(java.io.InputStream stream)
Reads the stream to the end and returns the bytes read.
|
@Nullable public static java.io.InputStream convertBytesToStream(@NotNull byte[] data)
data
- The data to convert to a stream@Nullable public static java.io.InputStream convertBytesToStream(@NotNull byte[] data, @Nullable java.util.concurrent.ThreadPoolExecutor pool)
data
- The data to convert to a streampool
- The thread pool to use for the background thread@NotNull public static byte[] read(@NotNull java.io.InputStream inputStream, int length) throws java.io.IOException
inputStream
- The stream to read fromlength
- The number of bytes to readjava.io.IOException
- If an error occurs while reading the streampublic static byte[] readFully(@NotNull java.io.InputStream stream) throws java.io.IOException
stream
- The stream to readjava.io.IOException
- On error reading from the stream.