Java Email Validate checkEmail(String email)

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

Description

Check email.

License

LGPL

Parameter

Parameter Description
email the email

Return

true, if successful

Declaration

public static boolean checkEmail(String email) 

Method Source Code

//package com.java2s;
/**/*from   ww w  .j  a  v a2  s.  c o  m*/
 * Highlights words in a string. Words matching ignores case. The actual
 * higlighting method is specified with the start and end higlight tags.
 * Those might be beginning and ending HTML bold tags, or anything else.
 * <p>
 * 
 * This method is under the Jive Open Source Software License and was
 * written by Mark Imbriaco.
 *
 * @param string
 *            the String to highlight words in.
 * @return a new String with the specified words highlighted.
 */

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

public class Main {
    /**
     * Check email.
     *
     * @param email
     *            the email
     * @return true, if successful
     */
    public static boolean checkEmail(String email) {
        String ps = "^([\\w-\\.]+)@[\\w-.]+(\\.?[a-zA-Z]{2,4}$)";
        Pattern p = Pattern.compile(ps);
        Matcher m = p.matcher(email);
        if (m.matches()) {
            return true;
        } else {
            return false;
        }

    }
}

Related

  1. baseAddress(String email)
  2. checkEmail(String email)
  3. checkEmail(String email)
  4. checkEmail(String email)
  5. checkEmail(String mail)
  6. checkEmailAddress(String address)