Here you can find the source of getRandomString(int length)
public static String getRandomString(int length)
//package com.java2s; /*//from ww w.ja va 2 s .c o m * oxCore is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. * * Copyright (c) 2014, Gluu */ import java.util.Random; public class Main { private static final String charset = "!0123456789abcdefghijklmnopqrstuvwxyz"; private static Random rand; public static String getRandomString(int length) { if (rand == null) { rand = new Random(System.currentTimeMillis()); } StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { int pos = rand.nextInt(charset.length()); sb.append(charset.charAt(pos)); } return sb.toString(); } public static String toString(Object[] array) { int len = array.length; if (len == 0) return ""; StringBuffer buf = new StringBuffer(len * 12); for (int i = 0; i < len - 1; i++) { buf.append(array[i]).append(", "); } return buf.append(array[len - 1]).toString(); } public static String toString(Object object) { return (object == null) ? null : object.toString(); } }