Here you can find the source of generateRandomEmailAddress(String domain)
Parameter | Description |
---|---|
domain | For example: google.com |
public static String generateRandomEmailAddress(String domain)
//package com.java2s; public class Main { /**/*from w w w .j a v a 2 s. com*/ * Generates random email address with specified domain * * @param domain * For example: google.com * @return Random email address as string */ public static String generateRandomEmailAddress(String domain) { String emailAddress = ""; // Generate random email address String alphabet = "abcdefghijklmnopqrstuvwxyz"; while (emailAddress.length() < 5) { int character = (int) (Math.random() * 26); emailAddress += alphabet.substring(character, character + 1); } emailAddress += Integer.valueOf((int) (Math.random() * 99)) .toString(); emailAddress += "@" + domain; return emailAddress; } }