您的位置:首页 > 编程语言 > Java开发

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

2013-09-05 20:59 441 查看
伪代码如下,自行整理.

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


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jar java eclipse j2se