Java Email Validate validateEmail(String email)

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

Description

validate Email

License

Open Source License

Declaration

public static boolean validateEmail(String email) 

Method Source Code


//package com.java2s;
import java.util.Collection;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static final Pattern EMAIL_PATTERN = Pattern.compile(".+@.+\\.[a-z]+");

    public static boolean validateEmail(String email) {
        return validatePattern(email, EMAIL_PATTERN);
    }/*from ww w .j a v  a2 s.co m*/

    private static boolean validatePattern(String toBeValidated, Pattern pattern) {
        if (isEmpty(toBeValidated))
            return false;
        Matcher m = pattern.matcher(toBeValidated);
        return m.matches();
    }

    public static boolean isEmpty(Collection<?> collection) {
        return collection == null || collection.size() == 0;
    }

    public static boolean isEmpty(Map<?, ?> map) {
        return map == null || map.size() == 0;
    }

    public static boolean isEmpty(String s) {
        return s == null || s.trim().length() == 0;
    }

    public static boolean isEmpty(Object[] array) {
        return array == null || array.length == 0;
    }
}

Related

  1. isValidEmailAddress(String emailAddress)
  2. isValidEmailAddress(String emailAddress)
  3. isValidEmailAddress(String emailAddress)
  4. isValidEmailAdress(String email)
  5. parseEmail(String target)
  6. validateEmail(String email)
  7. validateEmail(String email)
  8. validateEmail(String email)
  9. validateEmail(String email)