Java tutorial
//package com.java2s; //License from project: Open Source License public class Main { public static final String CHARSET_ALPHA_LOWER = "abcdefghijklmnopqrstuvwxyz"; public static String randomString(int len) { return randomString(len, CHARSET_ALPHA_LOWER); } public static String randomString(int len, String charset) { String out = ""; for (int i = 0; i < len; i++) { out += charset.charAt((int) (Math.random() * charset.length())); } return out; } }