Java Email Validate isValidEmail(String email)

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

Description

To check the passed email is valid or not.

License

Apache License

Parameter

Parameter Description
email String

Return

TRUE on valid email, false otherwise.

Declaration

public static boolean isValidEmail(String email) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.regex.Pattern;

public class Main {
    private static final Pattern VALID_EMAIL_REGEX_PATTERN = Pattern
            .compile("^[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,6}$",
                    Pattern.CASE_INSENSITIVE);

    /**/*from   w w  w . j  a va2 s. co  m*/
     * To check the passed email is valid or not.
     *
     * @param email String
     * @return TRUE on valid email, false otherwise.
     */
    public static boolean isValidEmail(String email) {
        final boolean isValidEmail = VALID_EMAIL_REGEX_PATTERN.matcher(
                email).matches();
        if (!isValidEmail) {
            System.out.println("Invalid email : " + email);
        }
        return isValidEmail;
    }
}

Related

  1. isValidEmail(String email)
  2. isValidEmail(String email)
  3. isValidEmail(String email)
  4. isValidEmail(String email)
  5. isValidEmail(String email)
  6. isValidEmail(String emailAddress)
  7. isValidEmail(String eMailAddress)
  8. IsValidEmail(String input)
  9. isValidEmailAddr(String str)