我对输入输出流有一个奇怪的问题,却一直无法理解。
我使用InputStream从资源文件中读取属性文件,代码如下:
它成功找到并读取了我的文件。我尝试像这样写入修改后的设置:
Properties prop = new Properties();
InputStream in = getClass().getResourceAsStream( "/resources/SQL.properties" );
rop.load(in);
return prop;
它成功找到并读取了我的文件。我尝试像这样写入修改后的设置:
prop.store(new FileOutputStream( "/resources/SQL.properties" ), null);
我遇到了一个存储时的奇怪错误:
java.io.FileNotFoundException: \resources\SQL.properties (The system cannot find the path specified)
那么为什么属性路径会改变?如何修复这个问题? 我正在使用Windows上的Netbeans