Java ThreadLocalRandom generateString(Random rng, String characters, int length)

Here you can find the source of generateString(Random rng, String characters, int length)

Description

generate String

License

Apache License

Declaration

private static String generateString(Random rng, String characters, int length) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.Random;

import java.util.concurrent.ThreadLocalRandom;

public class Main {
    private static String generateString(Random rng, String characters, int length) {
        char[] text = new char[length];
        for (int i = 0; i < length; i++) {
            text[i] = characters.charAt(rng.nextInt(characters.length()));
        }//from  ww w  .  j  av  a  2 s .com
        return new String(text);
    }

    public static String generateString(int length) {
        return generateString(ThreadLocalRandom.current(), "abcdefghi123456zxcv", length);
    }
}

Related

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