Java Email Validate checkEmailAddress(String address)

Here you can find the source of checkEmailAddress(String address)

Description

Check the given string to match the email format

License

Apache License

Parameter

Parameter Description
address - The given string to be checked as email address

Exception

Parameter Description
NullPointerException address is null.

Return

true if the given string is of email format. Other wise false

Declaration

public static boolean checkEmailAddress(String address) 

Method Source Code


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

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

public class Main {
    private static final Pattern PTN_EMAIL_ADDRESS = Pattern.compile("[\\w.-]+@[\\w.-]+");

    /**//from ww w  .  j av a 2s  .c  o  m
     * Check the given string to match the email format
     * 
     * @param address -
     *            The given string to be checked as email address
     * @return true if the given string is of email format. Other wise false
     * @throws NullPointerException
     *             address is null.
     */
    public static boolean checkEmailAddress(String address) {
        Matcher m = PTN_EMAIL_ADDRESS.matcher(address);
        return m.matches();
    }
}

Related

  1. checkEmail(String email)
  2. checkEmail(String email)
  3. checkEmail(String email)
  4. checkEmail(String email)
  5. checkEmail(String mail)
  6. checkEmailAddressNoEx(String inEmailAddress)
  7. checkEmailPattern(String email)
  8. checkEmailWithSuffix(String email)
  9. cleanUpEmailAddress(CharSequence address)