Here you can find the source of getRandomNumberString(int length)
public static String getRandomNumberString(int length)
//package com.java2s; import java.util.Random; public class Main { public static final String NUMBERS = "0123456789"; public static String getRandomNumberString(int length) { Random rand = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < length; i++) { int pos = rand.nextInt(NUMBERS.length()); sb.append(NUMBERS.charAt(pos)); }//from www . j a va 2s . com return sb.toString(); } public static String toString(Object obj) throws Exception { if (obj == null) { return ""; } else { return obj.toString(); } } }