public boolean validate(String addr){
  String namePart;
  String domainPart;
  StringTokenizer tok;
  int endindex=addr.indexOf('@');
  if (endindex == -1) {
    return false;
  }
  namePart=addr.substring(0,endindex);
  domainPart=addr.substring(endindex + 1,addr.length());
  tok=new StringTokenizer(namePart,".");
  while (tok.hasMoreTokens()) {
    if (!isValidLocalPart(tok.nextToken())) {
      return false;
    }
  }
  DomainValidator validator=new DomainValidator();
  if (!validator.validate(domainPart)) {
    return false;
  }
  return true;
}

public boolean validate ( String addr ) { String namePart ; String domainPart ; StringTokenizer tok ; int endindex = addr . indexOf ( '@' ) ; if ( endindex == - 1 ) { return false ; } namePart = addr . substring ( 0 , endindex ) ; domainPart = addr . substring ( endindex + 1 , addr . length ( ) ) ; tok = new StringTokenizer ( namePart , "." ) ; while ( tok . hasMoreTokens ( ) ) { if ( ! isValidLocalPart ( tok . nextToken ( ) ) ) { return false ; } } DomainValidator validator = new DomainValidator ( ) ; if ( ! validator . validate ( domainPart ) ) { return false ; } return true ; }
check if the given email address is valid
