Java Email Validate isEmail(CharSequence email)

Here you can find the source of isEmail(CharSequence email)

Description

is Email

License

Apache License

Declaration

public static boolean isEmail(CharSequence email) 

Method Source Code

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

import java.util.regex.Pattern;

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

    public static boolean isEmail(CharSequence email) {
        if (isEmpty(email))
            return false;
        return emailer.matcher(email).matches();
    }/*  w  w  w . j a  v  a2s . c  o  m*/

    public static boolean isEmpty(CharSequence input) {
        if (input == null || "".equals(input))
            return true;

        for (int i = 0; i < input.length(); i++) {
            char c = input.charAt(i);
            if (c != ' ' && c != '\t' && c != '\r' && c != '\n') {
                return false;
            }
        }
        return true;
    }

    public static boolean isEmpty(CharSequence... strs) {
        for (CharSequence str : strs) {
            if (isEmpty(str)) {
                return true;
            }
        }
        return false;
    }
}

Related

  1. getEmailListStr(String tempStr)
  2. getEmails(String str)
  3. getFirstEmailAddr(String s)
  4. getSafeMailAddr(String mailAddr)
  5. getSmtpPort(String email)
  6. isEmail(CharSequence input)
  7. isEmail(final String email)
  8. isEmail(final String s)
  9. isEmail(final String text)