Java examples for java.lang:String Random
get Random String
//package com.java2s; import java.util.Random; public class Main { private static final char[] SYMBOLS = "abcdefghijklmnopqrstuvwxyz0123456789" .toCharArray();// w w w.j a v a 2 s.c o m public static String getRandomString(int length) { StringBuilder stringBuilder = new StringBuilder(); Random random = new Random(); for (int i = 0; i < length; i++) { char c = SYMBOLS[random.nextInt(SYMBOLS.length)]; stringBuilder.append(c); } return stringBuilder.toString(); } }