|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.gc.iotools.stream.utils.StreamUtils
public final class StreamUtils
General utilities for handling streams.
| Method Summary | |
|---|---|
static byte[] |
read(InputStream source,
int size)
Read a specified amount of bytes from the source InputStream and place them into the returned byte array. |
static int |
tryReadFully(InputStream source,
byte[] buffer,
int offset,
int len)
Read bytes from the source InputStream into the buffer. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static byte[] read(InputStream source,
int size)
throws IOException
Read a specified amount of bytes from the source InputStream and place them into the returned byte array.
This utility ensures that either size bytes are read or the
end of the stream has been reached.
source - Stream from which the data is read.size - The maximum length of the data read.
null if the End Of File has been reached.
IOException - If the first byte cannot be read for any reason other than
end of file, or if the input stream has been closed, or if
some other I/O error occurs.
public static int tryReadFully(InputStream source,
byte[] buffer,
int offset,
int len)
throws IOException
Read bytes from the source InputStream into the
buffer.
This utility ensures that either len bytes are read or the
end of the stream has been reached.
source - Stream from which the data is read.buffer - the buffer into which the data is read.offset - the start offset in array buffer at which the
data is written.len - maximum length of the bytes read.
-1 if there is no more data because the end of the
stream has been reached.
IOException - If the first byte cannot be read for any reason other than
end of file, or if the input stream has been closed, or if
some other I/O error occurs.
NullPointerException - If b is null.
IndexOutOfBoundsException - If off is negative, len is
negative, or len is greater than
b.length - offInputStream.read(byte[] buf,int off, int len)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||