Developer's Daily Java Education - Test Projects
  front page | java | perl | unix | DevDirectory
   
Front Page
Java
Education
   
 


package com.devdaily.opensource.web.util;

import javax.mail.internet.InternetAddress;
import javax.mail.internet.AddressException;

public class Validator
{
  public static boolean isValidEmailAddress(String emailAddress)
  {
    if ( emailAddress == null ) return false;
    if ( emailAddress.indexOf('@') < 0 ) return false;
    if ( emailAddress.indexOf('.') < 0 ) return false;

    try
    {
      InternetAddress internetAddress = new InternetAddress(emailAddress);
      return true;
    }
    catch (AddressException ae)
    {
      return false;
    }
  }

}
Copyright 1998-2003 DevDaily Interactive, Inc.
All Rights Reserved.