in src/main/java/org/apache/commons/crypto/utils/IoUtils.java [67:79]
public static void readFully(final Input in, final long position, final byte[] buffer,
final int offset, final int length) throws IOException {
int nread = 0;
while (nread < length) {
final int nbytes = in.read(position + nread, buffer, offset + nread,
length - nread);
if (nbytes < 0) {
throw new IOException(
"End of stream reached before reading fully.");
}
nread += nbytes;
}
}