On 6/13/13 1:03 AM, Duncan Jones wrote: > Hi, > > A piece of code I write far too often is: > > ====== > public static byte[] getRandomBytes(int length) { > // validate length is non-negative > > byte[] result = new byte[length]; > RANDOM.nextBytes(result); > return result; > } > ====== > > Is there a place for something like this in Commons Lang? Or, better, > does this already exist in another commons project?
I would be +1 for adding this (modified to use the configured RandomGenerator) to the RandomDataGenerator class in o.a.c.math.random. The advantage of adding it to there is that that class allows the underlying PRNG to be configured by the user. I am not sure where this little method would fit in [lang]; but it might make sense to add there in the simple form above (with RANDOM static, I assume). Phil > > Duncan > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org