Here you can find the source of getString(int length)
public static String getString(int length)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static final char[] LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); private static Random r = new Random(); public static String getString(int length) { StringBuilder sb = new StringBuilder(length); while (length-- > 0) { sb.append(randomChar(LETTERS)); }//from w w w. j av a2s. c o m return sb.toString(); } private static char randomChar(char[] letters) { int index = r.nextInt(letters.length); return letters[index]; } }