public static String generateRandomString(int length){
  String AB="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
  Random rnd=new Random();
  StringBuilder sb=new StringBuilder(length);
  for (int i=0; i < length; i++)   sb.append(AB.charAt(rnd.nextInt(AB.length())));
  return sb.toString();
}

public static String generateRandomString ( int length ) { String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_" ; Random rnd = new Random ( ) ; StringBuilder sb = new StringBuilder ( length ) ; for ( int i = 0 ; i < length ; i ++ ) sb . append ( AB . charAt ( rnd . nextInt ( AB . length ( ) ) ) ) ; return sb . toString ( ) ; }
generate random string with given length
