Java Utililty Methods Random String

List of utility methods to do Random String

Description

The list of methods to do Random String are organized into topic(s).

Method

StringgetRandomString()
get Random String
Random random = new Random();
int randomName = random.nextInt(99999999);
return "" + randomName;
StringgetRandomString()
get Random String
return getRandomString(MIN_LEN, MAX_LEN);
StringgetRandomString()
get Random String
StringBuilder builder = new StringBuilder();
for (int i = 0; i < 10; i++) {
    builder.append(chars[random.nextInt(chars.length)]);
return builder.toString();
StringgetRandomString()
Returns a randomly generated string of up to 15 characters.

return getRandomString(15);
StringgetRandomString()
get Random String
String chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
StringBuilder sb = new StringBuilder();
Random r = new Random();
while (sb.length() < 12) {
    int index = (int) (r.nextFloat() * chars.length());
    sb.append(chars.charAt(index));
return sb.toString().toLowerCase();
...
StringgetRandomString()
get Random String
StringBuffer randStr = new StringBuffer();
for (int i = 0; i < 3; i++) {
    int number = getRandomNumber();
    char ch = CHAR_LIST.charAt(number);
    randStr.append(ch);
return randStr.toString();
StringgetRandomString()
get Random String
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 5; i++) {
    sb.append(components[random.nextInt(components.length)]);
sb.append(random.nextInt());
String result = sb.toString();
if (result.length() > 9) {
    result = result.substring(0, 9);
...
StringgetRandomString()
get Random String
return getRandomString(DEFAULT_LEN);
StringgetRandomString()
Generates Random String of length 6 to 10.
return randomstring(6, 15);
StringgetRandomString(final int len)
get Random String
StringBuilder sb = new StringBuilder();
int max = CHARACTORS.length();
for (int i = 0; i < len; i++) {
    sb.append(CHARACTORS.charAt(RANDOM_GENERATOR.nextInt(max)));
return sb.toString();