我想写入一个*.properties文件。这是我的代码:
properties = loadProperties("user.properties");//loads the properties file
properties.setProperty(username, password);
try {
properties.store(new FileOutputStream("user.properties"), null);
System.out.println("Wrote to propteries file!" + username + " " + password);
我没有遇到异常,但我也没有得到写入文件的输出。
这是我的文件结构: 感谢您的回答!!!
更新内容: 我使用以下方法加载属性文件:
InputStream in = ClassLoader.getSystemResourceAsStream(filename);
我的问题是,如何从特定路径加载它?
以下是我的“新”文件结构: