public void nextBytes(byte[] out, int offset, int length)
throws IllegalStateException
{
if (!initialised)
throw new IllegalStateException("not initialized");
if (length == 0)
return;
if (offset < 0 || length < 0 || offset + length > out.length)
throw new ArrayIndexOutOfBoundsException("offset=" + offset + " length="
+ length + " limit=" + out.length);
if (buffer == null)
throw new IllegalStateException("Random is shut down - do you have a static ref?");
if (ndx >= buffer.length) {
fillBlock();
ndx = 0;
}
int count = 0;
while (count < length) {
int amount = Math.min(buffer.length - ndx, length - count);
System.arraycopy(buffer, ndx, out, offset+count, amount);
count += amount;
ndx += amount;
if (ndx >= buffer.length) {
fillBlock();
ndx = 0;
}
}
}