Java Email Validate isEmail(String email)

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

Description

is Email

License

Open Source License

Declaration

public static boolean isEmail(String email) 

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 {

    public static boolean isEmail(String email) {
        if (isEmpty(email)) {
            return false;
        }//from ww w.ja  va  2s.c  o m
        String str = "^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";

        Pattern p = Pattern.compile(str);
        Matcher m = p.matcher(email);
        return m.matches();
    }

    public static boolean isEmpty(String string) {

        if (string == null || "".equals(string.trim())) {
            return true;
        }

        return false;

    }
}

Related

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