代码如下:
Properties props = new Properties();
InputStream is = getClass().getResourceAsStream("test.properties");
try{
props.load(is);
is.close();
System.out.println(props.getProperty("test"));
props.setProperty("test", "reset");
FileOutputStream fos = new FileOutputStream("test2",true);
props.store(fos, null);
fos.write("httpL//juncsu.blogcn.com".getBytes());
fos.close();
}catch(Exception ex){
ex.printStackTrace();
}
结果是属性文件的内容可以读出来,但是无法写进去,测试中FileOutputStream直接写入也没有反应。不知道什么情况会导致这样的问题?或者有其他写Properties的方法?
函数式编程
慕桂英3389331
慕后森
随时随地看视频慕课网APP