Package jodd.util

Class RandomString

java.lang.Object
jodd.util.RandomString

public class RandomString extends Object
Class that generates random strings.
  • Field Details

    • ALPHA_RANGE

      protected static final char[] ALPHA_RANGE
    • ALPHA_NUMERIC_RANGE

      protected static final char[] ALPHA_NUMERIC_RANGE
    • INSTANCE

      protected static final RandomString INSTANCE
    • rnd

      protected final SecureRandom rnd
  • Constructor Details

    • RandomString

      public RandomString()
      Creates new random string.
  • Method Details

    • get

      public static RandomString get()
      Returns default instance of RandomString.
    • random

      public String random(int count, char[] chars)
      Creates random string whose length is the number of characters specified. Characters are chosen from the set of characters specified.
    • random

      public String random(int count, String chars)
      Creates random string whose length is the number of characters specified. Characters are chosen from the set of characters specified.
    • random

      public String random(int count, char start, char end)
      Creates random string whose length is the number of characters specified. Characters are chosen from the provided range.
    • randomAscii

      public String randomAscii(int count)
      Creates random string whose length is the number of characters specified. Characters are chosen from the set of characters whose ASCII value is between 32 and 126 (inclusive).
    • randomNumeric

      public String randomNumeric(int count)
      Creates random string that consist only of numbers.
    • randomRanges

      public String randomRanges(int count, char... ranges)
      Creates random string whose length is the number of characters specified. Characters are chosen from the multiple sets defined by range pairs. All ranges must be in acceding order.
    • randomAlpha

      public String randomAlpha(int count)
      Creates random string of characters.
    • randomAlphaNumeric

      public String randomAlphaNumeric(int count)
      Creates random string of characters and digits.
    • randomBase64

      public String randomBase64(int count)
      Creates random string that contains only Base64 characters.