문제

Possible Duplicate:
What is the best Java email address validation method?

I need to know if there is any method in java to implement email validation for addresses like

xyz@yahoo.com,xyz@yahoo.co.in

도움이 되었습니까?

해결책

Use this code.

static Pattern emailPattern = Pattern.compile("[a-zA-Z0-9[!#$%&'()*+,/\\-_\\.\"]]+@[a-zA-Z0-9[!#$%&'()*+,/\\-_\"]]+\\.[a-zA-Z0-9[!#$%&'()*+,/\\-_\"\\.]]+");
public static boolean isValidEmail(String email) 
{       
    Matcher m = emailPattern.matcher(email);
        return !m.matches();
}

다른 팁

You could use org.apache.commons.validator.EmailValidator which is part of Apache Commons Validator.

Or use a Jsr-303 validation framework (e.g. Hibernate Validator) which offers a @Email validator.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top