×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Karthick Bala
Added: Jul 25, 2014 10:36 AM
Views: 10
Tags: no tags
  1.     public static boolean isValidEmailIdList(LinkedList<String> emailIDList) throws Exception {
  2.         for (String emailId : emailIDList) {
  3.             if (!isEmailValid(emailId)) {
  4.                 return false;
  5.             }
  6.         }
  7.         return true;
  8.     }    
  9.  
  10.     public static boolean isEmailValid(String value) throws Exception{
  11.         // Trim the email id before checking whether it is valid or not.
  12.         if(value != null && value.equals("")){
  13.              return true;
  14.         }else{
  15.             String pattern= "^[a-zA-Z0-9.+_-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$"; // No I18N
  16.             if(value.matches(pattern)){
  17.                    return true;
  18.             }else{
  19.                   return false;
  20.             }
  21.         }
  22.     }