私はこの方法を得ました:
public static boolean isValidEmailAddress(String email) {
boolean result = true;
try {
InternetAddress emailAddr = new InternetAddress(email);
emailAddr.validate();
} catch (AddressException ex) {
result = false;
}
return result;
}
しかし、それは私にこの例外を与えます:
javax.mail.internet.AddressParser.tokenizeAddress(AddressParser.java:645) での java.lang.NullPointerException .java:70) で javax.mail.internet.InternetAddress.(InternetAddress.java:61) で controller.CtrlUser.isValidEmailAddress(CtrlUser.java:166) で controller.CtrlSeller.register(CtrlSeller.java:41) で testController. CtrlSellerUnitTestCase.testRegister(CtrlSellerUnitTestCase.java:41)、sun.reflect.NativeMethodAccessorImpl.invoke0(ネイティブ メソッド)、sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)、sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:) 25) java.lang.reflect.Method.invoke(Method.java:597) org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45) で org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) で org.junit.runners. model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) で org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) で org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores. java:28) org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) で org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) で org.junit.runners.BlockJUnit4ClassRunner org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) の .runChild(BlockJUnit4ClassRunner.java:68) org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) で org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) ....