Java examples for java.util:Random String
get Random String
//package com.java2s; public class Main { static final String charFactory = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; public static String getRandomString(int length) { StringBuilder str = new StringBuilder(); int tempLength = charFactory.length(); for (int i = 0; i < length; i++) { double tempDouble = Math.random() * tempLength; int tempInt = (int) Math.floor(tempDouble); str.append(charFactory.charAt(tempInt)); }//from w w w . j a v a 2s .co m return str.toString(); } }