• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 256
  • Last Modified:

in my properties file file path should wriiten in this formar

in my properties file my file path should be wriiten in this format

inwardremittance=C\:\\inwardremittance\\six.txt
#InwardRemittance
#Mon May 09 19:12:08 IST 2011
inwardremittance=C\:\\inwardremittance\\empty1.txt
#InwardRemittance
#Mon May 09 19:12:08 IST 2011
inwardremittance=C\:\\inwardremittance\\empty2.txt
i want to write

inwardremittance=C:\\inwardremittance\\empty2.txt

i want to remove one backslash after c

how could i dothat
0
Manikandan Thiagarajan
Asked:
Manikandan Thiagarajan
  • 3
  • 2
1 Solution
 
CEHJCommented:
Try replacing:
s = s.replace("C\\", "C");

Open in new window

0
 
cmalakarCommented:
Use this.. to replace only the first occurrence.
value = value.replaceFirst("C\\", "C");

Open in new window

0
 
for_yanCommented:
Strange, but you really don't need to do anything - it removes it itself.
I just ran this example:

input in the file:

#Modified properties
#Mon May 09 09:14:03 PDT 2011
newproperty=value
property2=bbb
inwardremittance=C\:\\inwardremittance\\empty2.txt
property1=aaa

Open in new window




    DataInputStream in = new DataInputStream(new FileInputStream("my.properties"));
        Properties prop = new Properties();
        prop.load(in);
            String adm = prop.getProperty("inwardremittance");
            System.out.println(adm);
        in.close();

Open in new window


Output:

C:\inwardremittance\empty2.txt

Open in new window

0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
for_yanCommented:
I'm a little bit surprised myself, but I just ran it several times - an the output is above.
Did you try to print your property in your code after you loaded it from file?
0
 
CEHJCommented:
If what you're witnessing is *in the file* then you don't need to worry about it - the colon is a member of a class of characters that's already escaped. When it's read it will be unescaped
0
 
for_yanCommented:
Yes, that's waht I see
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now