Here you can find the source of getRandomString(int size)
Parameter | Description |
---|---|
size | a parameter |
public static String getRandomString(int size)
//package com.java2s; //License from project: LGPL public class Main { /**/*from ww w. j a va 2s . c o m*/ * * @param size * @return */ public static String getRandomString(int size) { char[] vals = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'Q', 'W', 'E', 'R', 'T', 'Z', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Y', 'X', 'C', 'V', 'B', 'N', 'M' }; String randomString = ""; java.util.Random rand = new java.util.Random(); for (int i = 0; i < size; i++) randomString += vals[rand.nextInt(size)]; return randomString; } }