public class StreamUtils extends Object
Modifier and Type | Method and Description |
---|---|
static void |
readFully(InputStream inputStream,
byte[] array,
int offset,
int size)
Reads an exact number of bytes from the given input stream.
|
static void |
skipFully(InputStream inputStream,
long size)
Skips an exact number of bytes from the given input stream.
|
public static void readFully(InputStream inputStream, byte[] array, int offset, int size) throws IOException
inputStream
- the input stream to read from.array
- the array that will contain the data read.offset
- the offset in the array of the first byte read.size
- the number of bytes to read.EOFException
- if the end of stream is reached before reading the given number of bytes.IOException
- if an error occurred when reading from the input stream.public static void skipFully(InputStream inputStream, long size) throws IOException
inputStream
- the input stream to skip from.size
- the number of bytes to skip.EOFException
- if the end of stream is reached before skipping the given number of bytes.IOException
- if an error occurred when reading from the input stream.