Java tutorial
//package com.java2s; import java.util.Random; public class Main { static Random random = new Random(); public static String getRandomString(int length) { String retVal = "1234567890"; StringBuilder sb = new StringBuilder(); for (int i = 0; i < length; i++) sb.append(retVal.charAt(random.nextInt(retVal.length()))); return sb.toString(); } }