IOUtilspublic class IOUtils extends Object
Constructors Summary |
---|
private IOUtils()
|
Methods Summary |
---|
public static int | readFully(java.io.InputStream in, byte[] b)Helper method, just calls readFully(in, b, 0, b.length)
return readFully(in, b, 0, b.length);
| public static int | readFully(java.io.InputStream in, byte[] b, int off, int len)Same as the normal in.read(b, off, len), but tries to ensure that
the entire len number of bytes is read.
If the end of file is reached before any bytes are read, returns -1.
Otherwise, returns the number of bytes read.
int total = 0;
for (;;) {
int got = in.read(b, off + total, len - total);
if (got < 0) {
return (total == 0) ? -1 : total;
} else {
total += got;
if (total == len)
return total;
}
}
|
|