Hi Everyone,
I was wondering if there was an easy way of storing file names / paths in property files. My problem centres on the escape sequence characters of \ and \\.
What I have is a fileName and path sotred in a properties file. At the end of my program I re write the location of the file (as it can change). However the user must be able to edit the properties file externally too, ie in a text editor.
At the moment I am forced to store the escape sequence
string ie
C:\\Test\\test.txt
Where if the user was to type it in manually he would type (or through cut an past from explorer)
C:\Test\test.txt
Similarly when writing it back to the file I also get
C:\Test\test.txt
As the escape sequence characters are converted to a single printable \
Example code of sorts
try {
java.util.Properties p = new java.util.Properties();
p.load(new java.io.FileInputStream("C:\\test.property"));
if (p.containsKey("FILE")) {
String fileName = (String)p.get("FILE");
System.out.println("File = " + fileName);
}
}
catch (Exception ex) {
ex.printStackTrace();
}
Can someone please explain how I persist a file name and path in a properties file so that I can read / write it and copy into / edit it without the need for the \\
Many thanks
Michael Lisser