Java-将文件位置写入属性文件 [英] Java - Writing file location to Properties file
本文介绍了Java-将文件位置写入属性文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将 FILEPATH 参数写入属性文件,如下所示.
I'm writing the FILEPATH parameter into the properties file like below..
String newFilePath = txtFilepath.getText();
Properties prop = new Properties();
java.io.File propFile = new File("src/com/app/tool/properties/settings.properties");
prop.setProperty("FILEPATH", newFilePath);
System.out.println("newFilePath "+newFilePath);
try {
prop.store(new FileOutputStream(propFile), "New File location");
} catch (IOException ex) {
ex.printStackTrace();
}
文件路径为 D:\ filelog.txt
在写作时,控制台的打印像..
While writing, the console prints like..
newFilePath D:\filelog.txt
但是当我打开属性文件时,内容就像..
But when I open the properties file, content is like..
FILEPATH=D\:\\filelog.txt.
有人建议我,我在这里真正的意思是..?
Anyone suggest me , what I'm really m(i)essing here ..?
推荐答案
只需调用 prop.get("FILEPATH")
.您会看到,就像您输入的一样,您将获得"D:\ filelog.txt".
Just call prop.get("FILEPATH")
. You will see that you get back "D:\filelog.txt", just as you put it in.
这篇关于Java-将文件位置写入属性文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文