--- jsr166/src/jdk8/java/util/SplittableRandom.java 2016/12/20 22:08:05 1.3 +++ jsr166/src/jdk8/java/util/SplittableRandom.java 2017/10/17 23:26:32 1.5 @@ -399,6 +399,26 @@ public final class SplittableRandom { } /** + * Fills a user-supplied byte array with generated pseudorandom bytes. + * + * @param bytes the byte array to fill with pseudorandom bytes + * @throws NullPointerException if bytes is null + * @since 10 + */ + public void nextBytes(byte[] bytes) { + int i = 0; + int len = bytes.length; + for (int words = len >> 3; words--> 0; ) { + long rnd = nextLong(); + for (int n = 8; n--> 0; rnd >>>= Byte.SIZE) + bytes[i++] = (byte)rnd; + } + if (i < len) + for (long rnd = nextLong(); i < len; rnd >>>= Byte.SIZE) + bytes[i++] = (byte)rnd; + } + + /** * Returns a pseudorandom {@code int} value. * * @return a pseudorandom {@code int} value @@ -792,8 +812,7 @@ public final class SplittableRandom { * @return a stream of pseudorandom {@code double} values, * each with the given origin (inclusive) and bound (exclusive) * @throws IllegalArgumentException if {@code streamSize} is - * less than zero - * @throws IllegalArgumentException if {@code randomNumberOrigin} + * less than zero, or {@code randomNumberOrigin} * is greater than or equal to {@code randomNumberBound} */ public DoubleStream doubles(long streamSize, double randomNumberOrigin,