Here you can find the source of isEmail(String str, boolean nullCheck)
public static boolean isEmail(String str, boolean nullCheck)
//package com.java2s; //License from project: Apache License import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean isEmail(String str, boolean nullCheck) { String checkPattern = "^([A-Za-z0-9_\\-\\.'])+@([A-Za-z0-9_\\-\\.])+\\.([A-Za-z]{2,6})$"; if (nullCheck == false || isRequired(str)) { return isRegex(str, checkPattern, nullCheck); } else {//ww w .j ava2 s .com return false; } } public static boolean isRequired(String str) { if (str == null || str.trim().length() == 0) { return false; } return true; } public static boolean isRegex(String str, String regex) { return isRegex(str, regex, false); } public static boolean isRegex(String str, String regex, boolean nullCheck) { if (nullCheck == false || isRequired(str)) { Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); return matcher.matches(); } else { return false; } } }