Java ThreadLocalRandom generateString(int length)

Here you can find the source of generateString(int length)

Description

generate String

License

Open Source License

Declaration

public static String generateString(int length) 

Method Source Code

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

import java.util.concurrent.ThreadLocalRandom;

public class Main {
    public static final String allChar = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

    public static String generateString(int length) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < length; i++) {
            int index = ThreadLocalRandom.current().nextInt(allChar.length());
            sb.append(allChar.charAt(index));
        }/*from w w  w . j  a v a 2 s  .c o m*/
        return sb.toString();
    }
}

Related

  1. createRandomNumbers(int length)
  2. generateDescription()
  3. generateRandomDoubleVector(int dimension, double bottomLimit, double topLimit)
  4. generateRandomisedId()
  5. generateRandomSalt(int saltSize)
  6. generateString(Random rng, String characters, int length)
  7. generateStringFromCharacters(final Random random, final char[] validChars, final int min, final int max)
  8. genRandomString()
  9. get_a_number_between_min_and_max(int min, int max)