Here you can find the source of RandomString(int length)
public static String RandomString(int length)
//package com.java2s; //License from project: Open Source License import java.util.concurrent.ThreadLocalRandom; public class Main { public static String RandomString(int length) { String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; // Random random = new Random(); StringBuffer buf = new StringBuffer(); for (int i = 0; i < length; i++) { // int num = random.nextInt(62); int num = ThreadLocalRandom.current().nextInt(62); buf.append(str.charAt(num)); }/*w ww . ja v a 2s.c o m*/ return buf.toString(); } }