Here you can find the source of getRandomNum(int len)
public static String getRandomNum(int len)
//package com.java2s; //License from project: LGPL import java.util.Random; public class Main { public static String getRandomNum(int len) { Random random = new Random(); StringBuffer strNum = new StringBuffer(); for (int i = 0; i < len; i++) { int num = random.nextInt(10); strNum.append(num);//from ww w . j a va2 s . c o m } return strNum.toString(); } }