Here you can find the source of getRandomString(int size)
public static String getRandomString(int size)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { private final static char[] c = { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M' }; private final static int CHART_LENGHT = c.length; public static String getRandomString(int size) { Random random = new Random(); StringBuffer sb = new StringBuffer(size); for (int i = 0; i < size; i++) { sb.append(c[Math.abs(random.nextInt(CHART_LENGHT))]); }/*www. j av a 2s. c o m*/ return sb.toString(); } }