Here you can find the source of generatePassword()
public static String generatePassword() throws Exception
//package com.java2s; //License from project: Apache License import java.util.Random; public class Main { public static String generatePassword() throws Exception { try {/*w w w .ja va2 s .c o m*/ char[] charArray = "abcdefghijklmnopqrstuvwxyz".toCharArray(); StringBuilder stringBuilder = new StringBuilder(); Random random = new Random(); for (int i = 0; i < 10; i++) { char c = charArray[random.nextInt(charArray.length)]; stringBuilder.append(c); } String randomPassword = stringBuilder.toString(); return randomPassword; } catch (Exception e) { throw new Exception("Password generation failed!"); } } }