Here you can find the source of getNum(int length)
public static String getNum(int length)
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { public static String getNum(int length) { Random rm = new Random(); int pross = (int) (rm.nextDouble() * Math.pow(10, length)); return String.format("%0" + length + "d", pross); }// w ww . j a v a 2 s.co m }