Here you can find the source of getRandomString(int len, boolean ascii_only)
private static String getRandomString(int len, boolean ascii_only)
//package com.java2s; import java.util.Random; public class Main { private static String getRandomString(int len, boolean ascii_only) { Random r = new Random(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < len; i++) { char c; if (ascii_only) { c = (char) r.nextInt(62); if (c < 10) { c = (char) (48 + c); } else if (c < 36) { c = (char) (65 + c - 10); } else { c = (char) (97 + c - 36); }/*from w w w . jav a2s . c o m*/ } else { c = (char) (r.nextInt(94) + 32); } // if (c == '{' || c == '}' || c == '`') // { // continue; // } sb.append(c); } return sb.toString(); } }