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");
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从properties文件中读取和写入属性
- Java配置文件Properties的读取、写入与更新操作
- java 如何读取jar包外的properties文件(转)
- java IO 使用Properties设置键值对配置信息 写入文件和从文件中读取
- java中经常用到的读写配置文件的信息properties属性的写入,读取例子
- (转)实现对Java配置文件Properties的读取、写入与更新操作
- java从properties文件中读取和写入属性
- Java配置文件Properties的读取、写入与更新操作
- Java配置文件Properties的读取、写入与更新操作
- 关于java读取和写入properties配置文件的内容
- java 如何读取jar包外的properties文件(转)
- 对Java配置文件Properties的读取、写入与更新操作
- 对Java配置文件Properties的读取、写入与更新操作
- java从jar包中读取xml|properties文件
- java读取jar包中的资源文件或properties配置文件路径的方法
- Java配置文件Properties的读取、写入与更新操作
- java读取jar包中的资源文件或properties配置文件路径的方法
- 【Java编程】写入、读取、遍历Properties文件
- java读写properties文件,解决系统找不到指定路径,解决写入后读取正常,但文件数据未更新问题
- 用java代码实现从excel表格读取数据然后写入生成国际化配置文件properties