package com.uuzone.comp.wite; import java.io.FileInputStream; import java.io.IOException; import java.util.HashMap; import java.util.Map; import java.util.Properties; public class PropertiesLoader ... { public static Map loadProperties(String configFile) ...{ Properties properties = new Properties(); FileInputStream fileStream = null; Map<String, String> map = new HashMap<String, String>(); try ...{ fileStream = new FileInputStream(configFile); properties.load(fileStream); // properties.loadFromXML(fileStream); if (properties == null) ...{ System.out .println("config file " + configFile + " not loaded!"); } else ...{ String smtpHost = properties.getProperty("smtpHost", "smtp.gmail.com"); String emailUser = properties.getProperty("emailUser", "uuzonemail"); String emailPassword = properties.getProperty("emailPassword", "1qaz2wsx"); map.put("smtpHost", smtpHost); map.put("emailUser", emailUser); map.put("emailPassword", emailPassword);// String str1 = properties.getProperty("a", "11");// String str2 = properties.getProperty("b", "22");// System.out.println(str1);// System.out.println(str2); } } catch (IOException e) ...{ System.out.println("Could not find "" + configFile + ""!"); } finally ...{ try ...{ fileStream.close(); properties = null; } catch (IOException e) ...{ } } return map; } public static void main(String args[]) ...{ System.out.println(loadProperties("E:/test.properties")); }}