您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

分享在java中如何读取配置文件?

2025/12/31 9:28:53发布18次查看
分享在java中如何读取配置文件?下面就为大家介绍一下,代码如下:
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中如何读取配置文件?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product