Here you can find the source of randomStr(int length)
public static String randomStr(int length)
//package com.java2s; import java.util.Random; public class Main { public static String randomStr(int length) { String hash = ""; String charStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"; char chars[] = charStr.toCharArray(); int max = chars.length; Random random = new Random(); for (int i = 0; i < length; i++) { hash += chars[Math.abs(random.nextInt()) % max]; }//from www .j av a2 s . c om return hash; } }