public static String random(int length){
  Random rand=new Random(System.currentTimeMillis());
  StringBuilder sb=new StringBuilder();
  while (length > 0) {
    sb.append(chars[rand.nextInt(chars.length - 1)]);
    length--;
  }
  return sb.toString();
}

public static String random ( int length ) { Random rand = new Random ( System . currentTimeMillis ( ) ) ; StringBuilder sb = new StringBuilder ( ) ; while ( length > 0 ) { sb . append ( chars [ rand . nextInt ( chars . length - 1 ) ] ) ; length -- ; } return sb . toString ( ) ; }
generate a random string with the length .
