Here you can find the source of checkMail(String email)
public static boolean checkMail(String email)
//package com.java2s; import java.util.regex.Matcher; import java.util.regex.Pattern; public class Main { public static boolean checkMail(String email) { String input = "@sun.com"; // Checks for email addresses starting with // inappropriate symbols like dots or @ signs. Pattern p = Pattern.compile("^\\.|^\\@"); Matcher m = p.matcher(input); if (m.find()) return false; // Checks for email addresses that start with // www. and prints a message if it does. p = Pattern.compile("^www\\."); m = p.matcher(input);/*from ww w . ja va 2s. c om*/ if (m.find()) { return false; } p = Pattern.compile("[^A-Za-z0-9\\.\\@_\\-~#]+"); m = p.matcher(input); StringBuffer sb = new StringBuffer(); boolean result = m.find(); boolean deletedIllegalChars = false; while (result) { deletedIllegalChars = true; m.appendReplacement(sb, ""); result = m.find(); } // Add the last segment of input to the new String m.appendTail(sb); input = sb.toString(); if (deletedIllegalChars) { return false; } return true; } }