Save String that contains a windows file path with backslashes

  • Thread starter peter.o.mueller
  • Start date
P

peter.o.mueller

Hi all,

I want to store a String in a XML document using jdom. The string
contains some backslash chars becauase it is a path to an application
on Windows (e.g. c:\\fiels\ ...)

Jdom complains that is not possible to store backslash chars. One
solution is to replace the backslash chars before saving the string and
do the reverse when loading the XML file.

I used the replace method of the String class. But the backslash signs
gets not replaced. Any ideas?

Thanks,
Peter
 
R

Roedy Green

I used the replace method of the String class. But the backslash signs
gets not replaced. Any ideas?

See http://mindprod.com/jgloss/literals.html

In Java source you must double up every \. There is only actually one
in the String literal in the class file.

I just use / all the time for file names in Windows. It works just
fine. It bypasses the need for \\ quoting. The only time you need \
in when you are showing the end user the filename.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top