List of utility methods to do Random String
String | generateRandomStr(final int length) generate Random Str final StringBuilder builder = new StringBuilder(); for (int i = 0; i < length; i++) { builder.append(i); return builder.toString(); |
String | generateRandomStr(int length) Generate a random string. String candidateChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; StringBuilder sb = new StringBuilder(); Random random = new Random(); for (int i = 0; i < length; i++) { sb.append(candidateChars.charAt(random.nextInt(candidateChars.length()))); return sb.toString(); |
String | generateRandomString() Gnerate a new random string String str = ""; for (int i = 0; i < 10; i++) str += new Random().nextInt(); return str; |
String | generateRandomString() Generate a random String String characters = "abcdefghijklmnopqrstuvwxyz123456789"; int length = generateRandomNumber(); char[] text = new char[length]; for (int i = 0; i < length; i++) { text[i] = characters.charAt(random.nextInt(characters.length())); return new String(text); |
String | generateRandomString() generate Random String return generateRandomString(RANDOM_STRING_COUNT);
|
String | generateRandomString() generate Random String Random rnd = new Random(); if (rnd.nextInt(3) == 0) { return ""; } else { return "test" + rnd.nextInt(); |
String | generateRandomString() Generate random String , get its length , generate char list and append to random string generated. StringBuffer strBfrRandom = new StringBuffer(); for (int i = 0; i < RANDOM_STRING_LENGTH; i++) { int intNumber = getRandomNumber(); char character = CHAR_LIST.charAt(intNumber); strBfrRandom.append(character); return strBfrRandom.toString(); |
String | generateRandomString() Generates random string int s = RAND.nextInt(CHARS.length()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < MIN_NO_OF_CHARS + s; ++i) { sb.append(CHARS.charAt(RAND.nextInt(CHARS.length()))); return sb.toString(); |
String | generateRandomString() generate Random String return Long.toHexString(Double.doubleToLongBits(Math.random()));
|
String | generateRandomString(final int minCharLen, final int maxCharLen) generate Random String if (minCharLen > maxCharLen) { throw new IllegalArgumentException( "Maximum Character Length must be larger than the Minimum Character Length"); StringBuilder builder = new StringBuilder(); generateCharacterList(); int len = (int) (Math.random() * (minCharLen - maxCharLen)) + minCharLen; Random r = new Random(); ... |