Java Email Validate checkEmail(String email)

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

Description

check Email

License

Open Source License

Declaration


public static boolean checkEmail(String email) 

Method Source Code


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

public class Main {

    public static boolean checkEmail(String email) {
        boolean flag = false;
        try {//from www.  j  ava2s .com
            String check = "^([a-z0-9A-Z]+[-|_|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$";
            Pattern regex = Pattern.compile(check);
            Matcher matcher = regex.matcher(email);
            flag = matcher.matches();
        } catch (Exception e) {
            flag = false;
        }
        return flag;

    }
}

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)
  7. checkEmailAddressNoEx(String inEmailAddress)