Here you can find the source of generateRandomString(int count)
public static String generateRandomString(int count)
//package com.java2s; /**/*from w w w . j a v a 2s . c o m*/ * (C) 2011-2012 Alibaba Group Holding Limited. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * version 2 as published by the Free Software Foundation. * */ import java.util.Random; public class Main { /** * Generate a random string. This is used for password encryption. * * @return the generated random String */ public static String generateRandomString(int count) { Random random = new Random(); StringBuffer buffer = new StringBuffer(); while (count-- != 0) { // a random number in the 32...127 range char ch = (char) (random.nextInt(96) + 32); buffer.append(ch); } return buffer.toString(); } }