Here you can find the source of getRandomPassword()
public static String getRandomPassword()
//package com.java2s; //License from project: Apache License import java.util.Random; import java.util.concurrent.ThreadLocalRandom; public class Main { private static char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()" .toCharArray();//from ww w .ja v a 2s.c om public static String getRandomPassword() { Random random = ThreadLocalRandom.current(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < 5 + random.nextInt(15); i++) { char c = chars[random.nextInt(chars.length)]; sb.append(c); } return sb.toString(); } }