RandomStringUtils.random3 : RandomStringUtils « Apache Common « Java Tutorial






import org.apache.commons.lang.RandomStringUtils;

public class MainClass {
    public static void main(String[] args) {
      //Random 8 chars string using only the elements in the array aChars
      //Only charcters between place 0 and 5 in the array can be used.
      //Both letters and numbers are permitted
      System.out.print("5) 8 char string using specific characters in an array >>>");

      char[] aChars = new char[] { 'a', '1', 'c', '2', 'e', 'f', 'g' };
      System.out.println(RandomStringUtils.random(8, 0, 5, true, true, aChars));

    }
}
4) 8 char string -Alphabets only >>>WOjFhopO
  Download:  CommonLangRandomStringUtils.random3.zip( 199 k)







37.11.RandomStringUtils
37.11.1.RandomStringUtils.randomNumeric
37.11.2.RandomStringUtils.randomAlphanumeric
37.11.3.RandomStringUtils.randomAlphabetic
37.11.4.RandomStringUtils.random3
37.11.5.RandomStringUtils.random2
37.11.6.RandomStringUtils.random