public static String generateCode(int codeSize){
  Random sr=new Random();
  char[] randomChars=new char[codeSize];
  randomChars[0]=letters.charAt(sr.nextInt(letters.length()));
  for (int i=1; i < codeSize; ++i) {
    randomChars[i]=ALLOWED_CHARS.charAt(sr.nextInt(NUMBER_OF_CODEPOINTS));
  }
  return new String(randomChars);
}

public static String generateCode ( int codeSize ) { Random sr = new Random ( ) ; char [ ] randomChars = new char [ codeSize ] ; randomChars [ 0 ] = letters . charAt ( sr . nextInt ( letters . length ( ) ) ) ; for ( int i = 1 ; i < codeSize ; ++ i ) { randomChars [ i ] = ALLOWED_CHARS . charAt ( sr . nextInt ( NUMBER_OF_CODEPOINTS ) ) ; } return new String ( randomChars ) ; }
generates a pseudo random string using the allowed characters .
