How to validate an email address

How do you validate an email address?

Must start with characters or digits, which may be separated with . or _  and contain the @ symbol. Top second and third level names must be separated with . character and end in top level domain (.com  .net  or

The constructor should take a single STRING argument, the email address. If it's malformed (not valid) it should throw a MalformedEmailException with appropriate message.

Can anybody help, 'cos I'm lost here!

Many Thanks
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

what exactly u want?
There are Perl Scripts that can validate an email address, not sure about any Java source.
Wait! I did find Java package for regular expressions:

Here is an expression from Perl FAQ to validate email addresses, but it does not handle all of them:
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Try Java Mail API and try to use EXPN command. EXPN returns the information about the particular email-id from the email server.

if((checkstring==null)||(checkstring.indexOf("@")==1)||(checkstring.indexOf(".")=-1)||(checkstring.indexOf("@")==0) || (checkstring.indexOf("@")+1)==(checkstring.indexOf("."))||( checkstring.indexOf(".")+2)>=checkstring.length())
            return false;
      String subcheck = checkstring.substring(checkstring.indexOf(".")+1,checkstring.length());
      if (subcheck.length()>0)
            int l = subcheck.length();
            char[] ch = new char[l];
              for(int i=0;i<l;i++)
                     return false;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.