Save String that contains a windows file path with backslashes

Discussion in 'Java' started by peter.o.mueller@gmx.de, Sep 5, 2005.

  1. Guest

    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
     
    , Sep 5, 2005
    #1
    1. Advertisements

  2. Roedy Green Guest

    On 5 Sep 2005 11:45:03 -0700, wrote or quoted :

    >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.

    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Again taking new Java programming contracts.
     
    Roedy Green, Sep 5, 2005
    #2
    1. Advertisements

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. James Dyer
    Replies:
    5
    Views:
    920
  2. Replies:
    17
    Views:
    1,071
    Hiran Chaudhuri
    Dec 6, 2005
  3. Alastair Cameron
    Replies:
    1
    Views:
    8,180
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  4. Replies:
    15
    Views:
    980
    Charles Richmond
    Apr 10, 2005
  5. Replies:
    2
    Views:
    553
    George Sakkis
    Jul 13, 2005
  6. Tobias Reif
    Replies:
    6
    Views:
    261
    Tobias Reif
    Sep 3, 2003
  7. dkmd_nielsen

    Windows PATH contains trunk

    dkmd_nielsen, Mar 14, 2007, in forum: Ruby
    Replies:
    0
    Views:
    144
    dkmd_nielsen
    Mar 14, 2007
  8. Peng Yu
    Replies:
    3
    Views:
    316
    C.DeRykus
    Jul 13, 2010
Loading...