I have a .properties file I want to load in a Java Properties object. The file contains some paths. In order to be able to load the properties file without getting a java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
when loading the properties from the file with the method Properties.load(), I need to use the escape character '\' in the path.
So my path looks like: C:\\Users\\Harald\\Folder1\\Version1\\Folder2
. And it works this way, no exception is thrown.
The problem is that I can't explain to my user (because this path can be changed by the user!) that he needs to use double '\' in the path.
Does anybody knows a work-around for this problem? Thanks!
when loading the properties from the file with the method Properties. load(), I need to use the escape character '\' in the path. So my path looks like: C:\\Users\\Harald\\Folder1\\Version1\\Folder2 . And it works this way, no exception is thrown.
The path for a file can be obtained using the method java. io. File. getPath().
Even simpler solution is to use forward slashes. This way your path will look like C:/Users/Harald/Folder1/Version1/Folder2
and everything else will just work - no code change required!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With