Java Random String generateRandomString(Random rnd, char[] alphabet, int maxLength)

Here you can find the source of generateRandomString(Random rnd, char[] alphabet, int maxLength)

Description

generate Random String

License

Open Source License

Declaration

public static String generateRandomString(Random rnd, char[] alphabet, int maxLength) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    public static String generateRandomString(Random rnd, char[] alphabet, int maxLength) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < (rnd.nextInt(maxLength) + 1); i++) {
            sb.append(alphabet[rnd.nextInt(alphabet.length)]);
        }// ww w .j  av  a 2s  .  c om
        return sb.toString();
    }
}

Related

  1. generateRandomString(int size)
  2. generateRandomString(int stringLength)
  3. generateRandomString(int wordsLength, String separator)
  4. generateRandomString(Random random, int length)
  5. generateRandomString(Random random, int size)
  6. generateRandomString(String str, int length)
  7. genRandomString()
  8. genRandomString(final int length)
  9. genRandomString(int count)