Here you can find the source of getRandomString(final int len)
Parameter | Description |
---|---|
len | a parameter |
public static synchronized final String getRandomString(final int len)
//package com.java2s; //License from project: Open Source License import java.util.Random; public class Main { /**// w w w. j av a 2 s .c om * Get random string * * @param len * @return */ public static synchronized final String getRandomString(final int len) { final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; final Random rnd = new Random(); final StringBuilder sb = new StringBuilder(len); for (int i = 0; i < len; i++) { sb.append(AB.charAt(rnd.nextInt(AB.length()))); } return sb.toString(); } }