Here you can find the source of generateRandomString(int size)
public static String generateRandomString(int size)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static String random_str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; public static String generateRandomString(int size) { String random = new String(); Random rand = new Random(); for (int i = 0; i < size; i++) { int random_nbr = rand.nextInt(random_str.length()); random += (rand.nextBoolean()) ? random_str.charAt(random_nbr) : Character.toLowerCase(random.charAt(random_nbr)); }//from ww w .j a v a 2 s. c om return random; } }