Java Email Validate isValidEmail(String email)

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

Description

Validate if the email is valid.

License

Apache License

Parameter

Parameter Description
email a parameter

Return

true: it is valid. Otherwise, it is invalid.

Declaration

public static boolean isValidEmail(String email) 

Method Source Code

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

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

public class Main {
    /**//from w w  w .j  a v a2  s.c  o m
     * Validate if the email is valid.
     * 
     * @param email
     * @return true: it is valid. Otherwise, it is invalid.
     */
    public static boolean isValidEmail(String email) {
        String check = "[a-zA-Z0-9\\+\\.\\_\\%\\-\\+]{1,256}" + "\\@" + "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}" + "("
                + "\\." + "[a-zA-Z0-9][a-zA-Z0-9\\-]{0,25}" + ")+";
        Pattern pattern = Pattern.compile(check);
        Matcher matcher = pattern.matcher(email);

        return matcher.matches();
    }
}

Related

  1. isValidEmail(final String email)
  2. isValidEmail(final String email)
  3. isValidEmail(String email)
  4. isValidEmail(String email)
  5. isValidEmail(String email)
  6. isValidEmail(String email)
  7. isValidEmail(String email)
  8. isValidEmail(String email)
  9. isValidEmail(String emailAddress)