Modifies the byte array by a random sequence of bytes generated by this random number generator. @param buf non-null array to contain the new random bytes. @see #next
(byte[] buf)
| 116 | * @see #next |
| 117 | */ |
| 118 | public void nextBytes(byte[] buf) { |
| 119 | int rand = 0, count = 0, loop = 0; |
| 120 | while (count < buf.length) { |
| 121 | if (loop == 0) { |
| 122 | rand = nextInt(); |
| 123 | loop = 3; |
| 124 | } else { |
| 125 | loop--; |
| 126 | } |
| 127 | buf[count++] = (byte) rand; |
| 128 | rand >>= 8; |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Generates a normally distributed random {@code double} number between 0.0 |