public class propertyutil { public static final properties prop = new properties(); /** * 读取配置文件的内容(key,value) * * @param key * @return key对应的value */ public static string get(string key) { if (prop.isempty()) { try { inputstream in = propertyutil.class.getresourceasstream(/config.properties); prop.load(in); in.close(); } catch (exception e) {} } return prop.getproperty(key); } }
在resources文件下新建config.properties文件
websitepath=e:\\code\\landtax\\landtax\\ standardcondition=\c_cd\<=0.2 filepathtdqs=d:\\webspace\\import\\\u571f\u5730\u6743\u5c5e\u4fe1\u606f.xlsx
调用方法
string filepathtdqs = propertyutil.get(filepathtdqs);
以上就是分享在java中如何读取配置文件?的详细内容。
