java - Not able to read Properties File using Backward Slash -
I am not able to read the properties file using Java. This means that the previous slash in this property file is not working. It is showing, like this destination: C: Usersxxx.a
string file name = "D: //Desktop//xxx.properties"; Is = new FileInputStream (file name); Properties PRO = new properties (); Prop.load (is); System.out.println ("Destination:" + prop.getProperty ("Destination"));
is the property file:
destination = c: \ user \ xxx.a \
is the result < / Code>
But I want to show the destination: C: \ Usersxxx.a \
Can you please recommend me?
\
is a surviving character.
Forward slash /
is used as a path separator in the Unix environment.
Slash \
is used as a path separator in the Windows environment.
, you need to use \\
or /
as a path separator, you do not use \
directly in java Can. Since, it is a surviving character.
So, you need to do the work of your program to make changes to your properties file. Use /
or \\
as a path separator in your properties file.
In your case you want to show as C: \ users \ xxx.a \
. >> Then, C: \\ user \\ xxx.a \\
Use
Comments
Post a Comment