Verify email in Java

后端 未结 9 1494
长发绾君心
长发绾君心 2020-12-02 11:27

Is there any way to verify in Java code that an e-mail address is valid. By valid, I don\'t just mean that it\'s in the correct format (someone@domain.subdomain), but that\'

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 11:57

    If you're using GWT, you can't use InternetAddress, and the pattern supplied by MBCook is pretty scary.

    Here is a less scary regex (might not be as accurate):

    public static boolean isValidEmail(String emailAddress) {
        return emailAddress.contains(" ") == false && emailAddress.matches(".+@.+\\.[a-z]+");
    }
    

提交回复
热议问题