Java tutorial
//package com.java2s; import java.util.Random; public class Main { public static String generateRandomString(final int len) { final String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; final Random random = new Random(); final StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i++) { final int number = random.nextInt(base.length()); sb.append(base.charAt(number)); } return sb.toString(); } }