Java Email Validate validateEmail(String email)

Here you can find the source of validateEmail(String email)

Description

Validates email

License

Open Source License

Parameter

Parameter Description
email The email to be validated

Return

boolean

Declaration

public static boolean validateEmail(String email) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    private static Pattern pattern;
    private static Matcher matcher;
    private static final String EMAIL_PATTERN = "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@"
            + "[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$";

    /**/*from ww  w  .jav  a 2s . c  o m*/
     * Validates email
     * 
     * @param email
     *            The email to be validated
     * @return boolean
     */
    public static boolean validateEmail(String email) {
        pattern = Pattern.compile(EMAIL_PATTERN);
        matcher = pattern.matcher(email);

        return matcher.matches();
    }
}

Related

  1. parseEmail(String target)
  2. validateEmail(String email)
  3. validateEmail(String email)
  4. validateEmail(String email)
  5. validateEmail(String email)
  6. validateEmail(String email)
  7. validateEmail(String email)
  8. validateEmail(String email)
  9. validateEmail(String hex)