1 23 package org.mdarad.framework.util; 24 25 import java.util.Enumeration ; 26 import java.util.MissingResourceException ; 27 import java.util.Properties ; 28 import java.util.ResourceBundle ; 29 30 36 public class PropertiesLoader { 37 38 public static Properties loadProperties(String resFile){ 39 40 try{ 41 ResourceBundle bundle = null; 42 try { 43 bundle = ResourceBundle.getBundle(resFile); 44 } catch(MissingResourceException mre) { 45 throw new RuntimeException (mre.getMessage()); 46 } 47 48 Properties properties = new Properties (); 49 for (Enumeration keys = bundle.getKeys (); keys.hasMoreElements ();){ 50 final String key = (String ) keys.nextElement (); 51 final String value = bundle.getString (key); 52 properties.put (key, value); 53 } 54 return properties; 55 }catch(Exception e){ 56 return null; 57 } 58 } 59 } 60 | Popular Tags |