Java Email Validate isEmail(String str)

Here you can find the source of isEmail(String str)

Description

is Email

License

Open Source License

Declaration

public static boolean isEmail(String str) 

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 final String EMAIL_PATTERN = "\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*";

    public static boolean isEmail(String str) {
        return isMatcher(str, EMAIL_PATTERN);
    }//from   w  ww  . ja v  a2  s  .com

    public static boolean isMatcher(String str, String pattern) {
        if (str == null) {
            return false;
        }
        if (pattern == null) {
            throw new IllegalArgumentException();
        }
        Pattern pt = Pattern.compile(pattern);
        Matcher mc = pt.matcher(str);
        return mc.matches();
    }
}

Related

  1. isEmail(String emailAddress)
  2. isEmail(String input)
  3. isEmail(String msg)
  4. isEmail(String s)
  5. isEmail(String str)
  6. isEmail(String str)
  7. isEmail(String str)
  8. isEmail(String str)
  9. isEmail(String str)