Is there any method to check if the email address is valid in Java?

Asked 1 years ago, Updated 1 years ago, 127 views

Is there any method to check if the email address is valid in Java? Or is it possible to implement it in code?

validation email java apache-commons

2022-09-22 22:16

1 Answers

It is easy to use the java email package.

public static boolean isValidEmailAddress(String email) {
   boolean result = true;
   try {
      InternetAddress emailAddr = new InternetAddress(email);
      emailAddr.validate();
   } } catch (AddressException ex) {
      result = false;
   }
   return result;
}


2022-09-22 22:16

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.