Here you can find the source of generateRandomString(int length)
public static String generateRandomString(int length)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { public static String generateRandomString(int length) { StringBuilder str = new StringBuilder(); String base = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; Random rnd = new Random(); for (int i = 0; i < length; i++) { str.append(base.charAt(rnd.nextInt(base.length()))); }//from w w w. j a va 2s.c om return str.toString(); } }