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

伪代码如下,自行整理.

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");


你可能感兴趣的:(java,eclipse,J2SE,jar)