Java examples for java.util:Random String
get Random Letter Lower Case
//package com.java2s; public class Main { private static final String ALPHA_NUMERIC = "ABCDEFGHJKLMNPQRSTUVWXYZ123456789"; public static String getRandomLetterLowerCase(int length) { return getRandomLetter(length).toLowerCase(); }//from w ww . j av a2s . co m public static String getRandomLetter(int length) { char[] randomBytes = new char[length]; for (int i = 0; i < length; i++) { randomBytes[i] = ALPHA_NUMERIC.charAt(getRangeRandom(0, ALPHA_NUMERIC.length() - 1)); } return new String(randomBytes); } public static int getRangeRandom(int min, int max) { return (int) (Math.random() * (max - min + 1) + min); } public static int getRangeRandom(int max) { return (int) (Math.random() * (double) max); } }