String filePath="src/cn/ac/iscas/pebble/ufe/conf/id.properties"; InputStream in = new BufferedInputStream(new FileInputStream(filePath)); int i = 0; Properties p = new Properties(); p.load(in); p.getProperty(key); 还有一个方式如下: public class ConfigUt
java项目里很多参数都是写在配置文件properties上,如果需要读取的话,可以使用jdk里提供的Properties类进行处理. 具体写法如下: public class PropertiesCfg { //配置文件所在目录路径,相对项目根目录,如果是放在根目录下,直接写文件名称就行 private final static String file = "config/myproperties.properties"; private final static Propertie