Here you can find the source of getRandomNumber(int len)
public static String getRandomNumber(int len)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { private static char[] m_chars = { '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'V', 'W', 'X', 'Y' }; private static Random m_ran = new Random(); public static String getRandomNumber(int len) { StringBuffer sb = new StringBuffer(); int p;//from w ww .j a v a2s. co m for (int i = 0; i < len; i++) { p = getRandomInt(0, m_chars.length); if (p < 0) p = 0; if (p >= m_chars.length) p = m_chars.length - 1; sb.append(m_chars[p]); } return sb.toString(); } public static int getRandomInt(int lo, int hi) { return lo + (int) ((hi - lo + 1) * m_ran.nextFloat()); } }