【发布时间】:2012-11-10 14:20:48
【问题描述】:
我目前正在加载这样的属性文件:
private Properties loadProperties(String filename) throws IOException{
InputStream in = ClassLoader.getSystemResourceAsStream(filename);
if (in == null) {
throw new FileNotFoundException(filename + " file not found");
}
Properties props = new Properties();
props.load(in);
in.close();
return props;
}
但是,目前我的文件位于 scr\user.properties 路径。
但是当我想写入属性文件时:
properties.setProperty(username, decryptMD5(password));
try {
properties.store(new FileOutputStream("user.properties"), null);
System.out.println("Wrote to propteries file!" + username + " " + password);
那段代码在我的项目的根文件夹级别生成了一个新文件。
但我想要一个文件来写\读。
那该怎么做呢?
PS.:当我想指定路径时,我得到“不允许修改文件...”
【问题讨论】:
-
也许尝试更改权限?
标签: java windows eclipse file properties