public final class InputStreamUtil
extends java.lang.Object
Modifier and Type | Field | Description |
---|---|---|
private static int |
SKIP_FRAGMENT_SIZE |
Constructor | Description |
---|---|
InputStreamUtil() |
Modifier and Type | Method | Description |
---|---|---|
static void |
readFully(java.io.InputStream in,
byte[] b,
int offset,
int len) |
Read a number of bytes into an array.
|
static int |
readLoop(java.io.InputStream in,
byte[] b,
int offset,
int len) |
Read a number of bytes into an array.
|
static int |
readUnsignedByte(java.io.InputStream in) |
Read an unsigned byte from an InputStream, throwing an EOFException
if the end of the input is reached.
|
static void |
skipFully(java.io.InputStream is,
long skippedBytes) |
Skips requested number of bytes,
throws EOFException if there is too few bytes in the stream.
|
static long |
skipPersistent(java.io.InputStream in,
long bytesToSkip) |
Tries harder to skip the requested number of bytes.
|
static long |
skipUntilEOF(java.io.InputStream is) |
Skips until EOF, returns number of bytes skipped.
|
private static final int SKIP_FRAGMENT_SIZE
public static int readUnsignedByte(java.io.InputStream in) throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.io.EOFException
- if the end of the stream is reachedDataInput.readUnsignedByte()
public static void readFully(java.io.InputStream in, byte[] b, int offset, int len) throws java.io.IOException
java.io.IOException
- if an I/O error occurs.java.io.EOFException
- if the end of the stream is reachedDataInput.readFully(byte[])
public static int readLoop(java.io.InputStream in, byte[] b, int offset, int len) throws java.io.IOException
java.io.IOException
- if an I/O error occurs.public static long skipUntilEOF(java.io.InputStream is) throws java.io.IOException
is
- InputStream to be skipped.java.io.IOException
- if IOException occurs. It doesn't contain EOFException.java.lang.NullPointerException
- if the param 'is' equals null.public static void skipFully(java.io.InputStream is, long skippedBytes) throws java.io.IOException
is
- InputStream to be skipped.skippedBytes
- number of bytes to skip. if skippedBytes ≷= zero, do nothing.java.io.EOFException
- if EOF meets before requested number of bytes are skipped.java.io.IOException
- if IOException occurs. It doesn't contain EOFException.java.lang.NullPointerException
- if the param 'is' equals null.public static final long skipPersistent(java.io.InputStream in, long bytesToSkip) throws java.io.IOException
Note that even if the method fails to skip the requested number of bytes, it will not throw an exception. If this happens, the caller can be sure that end-of-stream has been reached.
in
- byte streambytesToSkip
- the number of bytes to skipjava.io.IOException
- if reading from the stream failsApache Derby V10.14 Internals - Copyright © 2004,2018 The Apache Software Foundation. All Rights Reserved.