Class RandomStringFromAlphabetGenerator


  • public final class RandomStringFromAlphabetGenerator
    extends java.lang.Object
    Generates a random string from a predefined alphabet.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String generate​(java.lang.String alphabet, int length, java.util.Random random)
      Generate a random string from an alphabet.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • generate

        @Nonnull
        public static java.lang.String generate​(java.lang.String alphabet,
                                                int length,
                                                java.util.Random random)
        Generate a random string from an alphabet.
        Parameters:
        alphabet - the characters' alphabet to use
        length - the length of the returned string (greater than 0)
        random - Random (or better SecureRandom) used for generating the random string
        Returns:
        a random string of the requested length made of only characters from the provided alphabet