一、文件样式: 二、config.default.properties中的内容: weightpath=D:/harrypotter/xml/weight.xml dicpath=D:/harrypotter/xml/dictionary.xml dictionarypath=D:/harrypotter/cpv_dataset CHANGEPI=1 CHANGEPN=1 CHANGEPM=1 CHANGEPIC=1 CHANGEPIP=1 name=zhujiadun 三、操作代码 package com.taobao.jifeng.properties; import java.io.IOException; import java.io.InputStream; import java.util.Properties; public class TestProperties { public static void main(String[] args) { Properties properties = new Properties(); InputStream is = null; is = TestProperties.class.getResourceAsStream("/com/taobao/jifeng/properties/config.default.properties"); try { properties.load(is); String key = "name"; System.out.println(TestProperties.getValue(properties, key)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public static String getValue(Properties properties,String key) { if(properties.containsKey(key)) { String value = properties.getProperty(key); return value; } else { return ""; } } public static void clear(Properties properties) { properties.clear(); } public static void setValue(Properties properties,String key,String value) { properties.setProperty(key,value); } } 四、输出结果: zhujiadun