List of utility methods to do Random Int
void | randomQuickSort(int[] array) random quick sort randomQuickSort(array, 0, array.length); |
int | randomRange(int min, int max) random Range return min + (int) (Math.random() * ((max - min) + 1)); |
int | randomSize(int maxValue) random Size return randomIndex(maxValue) + 1;
|
String | randomSMSCode(int length) random SMS Code boolean numberFlag = true; String retStr = ""; String strTable = numberFlag ? "1234567890" : "1234567890abcdefghijkmnpqrstuvwxyz"; int len = strTable.length(); boolean bDone = true; do { retStr = ""; int count = 0; ... |
String | randomStr(int length) random Str return random(length, ALPHABET);
|
String | randomStr(int length, String charSet) Generates random alphanumeric String of the specified length using characters specified in charSet. char[] result = new char[length]; fillWithRandomChars(result, charSet); return new String(result); |
String | randomString(int count) random String StringBuilder b = new StringBuilder(); int len = chars.length(); for (int i = 0; i < count; i++) { b.append(chars.charAt((int) (Math.random() * len))); return b.toString(); |
String | randomString(int length) random String char[] guts = new char[length]; for (int i = 0; i < length; i++) { guts[i] = Character.toChars(65 + (int) (Math.random() * 26))[0]; return String.valueOf(guts); |
String | randomString(int length) Generate a random string of characters - including numbers StringBuffer b = new StringBuffer(length); for (int i = 0; i < length; i++) { b.append(randomAlpha()); return b.toString(); |
String | randomString(int length) random String String chars = "abcdefghijklmnopqrstuvwxyz" + "ABCDEFGHIFKLMNOPRSTUVWXYZ" + "0123456789"; StringBuffer buf = new StringBuffer(length); for (int i = 0; i < length; ++i) { int pos = (int) Math.round(Math.random() * (chars.length() - 1)); buf.append(chars.charAt(pos)); return buf.toString(); |