in src/main/java/org/apache/commons/crypto/utils/IoUtils.java [90:101]
public static void readFully(final InputStream in, final byte[] buf, int off, final int len)
throws IOException {
int toRead = len;
while (toRead > 0) {
final int ret = in.read(buf, off, toRead);
if (ret < 0) {
throw new IOException("Premature EOF from inputStream");
}
toRead -= ret;
off += ret;
}
}