Here you can find the source of generatePassword(int lenght)
public static String generatePassword(int lenght)
//package com.java2s; //License from project: Apache License public class Main { private static char[] _goodChar = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'j', 'k', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', '8', '9', '+', '-', '@', }; private static java.util.Random _random = new java.util.Random(); public static String generatePassword(int lenght) { StringBuffer sb = new StringBuffer(); for (int i = 0; i < lenght; i++) { sb.append(_goodChar[_random.nextInt(_goodChar.length)]); }// w w w. j a v a 2s .c o m return sb.toString(); } }