public class EMailValidator
{
public boolean validate(String email)
{
//Set the email pattern string
Pattern p = Pattern.compile(".+@.+\\.[a-z]+");
//Match the given string with the pattern
Matcher m = p.matcher(email);
//Check whether match is found
return m.matches();
}
public static void main(String arg[])
{
EMailValidator emailValidator = new EMailValidator();
boolean retVal = emailValidator.validate("prabir.karmakar@acclaris.com");
if(retVal)
System.out.println("It is valid email");
else
System.out.println("It is invalid email");
}
}
No comments:
Post a Comment