java解析属性文件
import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Iterator; import java.util.Properties; import java.util.Set; public class ParsePropertyFile { public HashMap<String, String> getProperty(String propertyFile) { HashMap<String, String> hm = null; try { Properties props = new Properties(); InputStream is = new FileInputStream( new File(propertyFile).getAbsolutePath()); props.load(is); Set<Object> keys = props.keySet(); hm = new HashMap<String, String>(); for (Iterator<Object> it = keys.iterator(); it.hasNext();) { String key = (String) it.next(); hm.put(key, props.getProperty(key)); } is.close(); } catch (IOException ie) { } return hm; } }
点亮测试人生!QQ:408129370
百度阅读电子书地址:http://yuedu.baidu.com/ebook/f6dbb2a2f01dc281e53af0f3
讨论QQ群:536192476
个人公众号:
百度阅读电子书地址:http://yuedu.baidu.com/ebook/f6dbb2a2f01dc281e53af0f3
讨论QQ群:536192476
个人公众号:
![](http://files.cnblogs.com/files/zhangfei/%E6%B5%8B%E8%AF%95%E5%BC%80%E5%8F%91%E6%B1%9F%E6%B9%96.bmp)