Wednesday, March 24, 2010

Email validation in Java

You can write your own code to validate email, but why bother if you have it ready. The Apache Commons project has a sub project called: Commons Validator. This project contains all sort of validation methods. One of the validations is used for email. In order to check if email address is valid all you have to do is:
EmailValidator.getInstance().isValid("some.mail.address@gmail.com");

Make sure to add the Commons Validator jar file and it's dependencies to your project.

No comments:

Post a Comment