title: Java - validate email with InternetAddress
body: <p>I got this method:</p>
  
  <pre><code>public static boolean isValidEmailAddress(String email) {
         boolean result = true;
         try {
            InternetAddress emailAddr = new InternetAddress(email);
            emailAddr.validate();
         } catch (AddressException ex) {
            result = false;
         }
         return result;
  }
  </code></pre>
  
  <p>but that give me this exception:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException    at
    javax.mail.internet.AddressParser.tokenizeAddress(AddressParser.java:645)
      at
    javax.mail.internet.AddressParser.parseAddress(AddressParser.java:113)
      at
    javax.mail.internet.InternetAddress.(InternetAddress.java:70)
      at
    javax.mail.internet.InternetAddress.(InternetAddress.java:61)
      at controller.CtrlUser.isValidEmailAddress(CtrlUser.java:166)   at
    controller.CtrlSeller.register(CtrlSeller.java:41)    at
    testController.CtrlSellerUnitTestCase.testRegister(CtrlSellerUnitTestCase.java:41)
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)  at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      at java.lang.reflect.Method.invoke(Method.java:597)     at
    org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
      at
    org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
      at
    org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
      at
    org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
      at
    org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
      at
    org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
      at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)    at
    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
      at
    org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
      at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)  at
    org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)   at
    org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) ....</p>
  </blockquote>