Java examples for java.util:Random
get Random Test Email
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashSet; import java.util.Set; public class Main{ public static String getRandomTestEmail() { return getRandomAlphaString(10) + "@" + RandomDataUtil.getRandomAlphaString(3) + ".server.com"; }/* w ww.j a va2 s . c o m*/ public static String getRandomAlphaString(int length) { StringBuilder b = new StringBuilder(); for (int i = 0; i < length; i++) { // ascii 60 to 90 char str = (char) (65 + (int) (Math.random() * (90 - 65))); b.append(str); } return b.toString(); } }