List of utility methods to do Random Long
long | randomLong(long x, long y) random Long return x + ((long) (Math.random() * (y - x))); |
long | randomLongWithMinMax(long min, long max) random Long With Min Max return (long) (min + (Math.random() * (max - min + 1))); |
void | randomSleep(long ms) Sleep for a short random amount of time try { Thread.sleep((long) (ms * Math.random())); } catch (InterruptedException e) { |
String | randomStr(long strLen) random Str char freshChar; String freshString; freshString = ""; while (freshString.length() < (strLen - 1)) { freshChar = (char) (Math.random() * 128); if (Character.isLetter(freshChar)) { freshString += freshChar; return (freshString); |
String | randomStr(long strLen) This is slow! char freshChar; StringBuilder sb = new StringBuilder(); while (sb.length() < (strLen - 1)) { freshChar = (char) (Math.random() * 128); if (Character.isLetter(freshChar)) { sb.append(freshChar); return sb.toString(); |
long | randPosLong() simply uses Math.random, only 0 and positive longs returned return randPosLong(Long.MAX_VALUE);
|
long | secureRandomLong() secure Random Long return UUID.randomUUID().getLeastSignificantBits();
|