java读取和写入jar包外的properties文件

来源:互联网 发布:js防水涂料品牌 编辑:程序博客网 时间:2024/06/04 18:38

伪代码如下,自行整理.

resource = new Properties();URL fileUrl = ClearTableMonthlyForBi.class.getClassLoader().getResource("clearTableForBi.properties");File propFile = new File(fileUrl.getFile());logger.info(propFile.getAbsolutePath());inStream = new FileInputStream(propFile);resource.load(inStream);monthStart = monthFormat.parse(resource.getProperty("start"));monthEnd = monthFormat.parse(resource.getProperty("end"));logger.info("clear table for BI data,start:" + monthStart + ",end:" + monthEnd);resource.setProperty("start", "");resource.setProperty("end", "");outStream = new FileOutputStream(propFile);resource.store(outStream, "need reset everytime for safe sade, format should be yyyyMM");