byte[] randomSeed = new byte[length];
int count = 0;
while (count < length) {
int bytesRead = file.read(randomSeed, count, length - count);
if (bytesRead == -1) {
throw new SeedException("EOF encountered reading random data.");
}
count += bytesRead;
}
return randomSeed;
} catch (IOException ex) {
throw new SeedException("Failed reading from " + DEV_URANDOM.getName(), ex);
} catch (SecurityException ex) {
// Might be thrown if resource access is restricted (such as in
// an applet sandbox).
throw new SeedException("SecurityManager prevented access to " + DEV_URANDOM.getName(), ex);
} finally {
if (file != null) {
try {
file.close();
} catch (IOException ex) {