Here you can find the source of getRandomString()
public static String getRandomString()
//package com.java2s; //License from project: Apache License public class Main { /**/*from ww w. ja v a2 s . com*/ * Generates Random String of length 6 to 10. * * @return */ public static String getRandomString() { return randomstring(6, 15); } public static String randomstring(int lo, int hi) { int n = rand(lo, hi); byte b[] = new byte[n]; for (int i = 0; i < n; i++) b[i] = (byte) rand('a', 'z'); return new String(b); } private static int rand(int lo, int hi) { java.util.Random rn = new java.util.Random(); int n = hi - lo + 1; int i = rn.nextInt() % n; if (i < 0) i = -i; return lo + i; } }