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

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

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:
    636
  2. Alastair Cameron
    Replies:
    1
    Views:
    7,364
    SQL Server Development Team [MSFT]
    Jul 8, 2003
  3. Replies:
    2
    Views:
    407
    George Sakkis
    Jul 13, 2005
  4. Tobias Reif
    Replies:
    6
    Views:
    111
    Tobias Reif
    Sep 3, 2003
  5. Peng Yu
    Replies:
    3
    Views:
    207
    C.DeRykus
    Jul 13, 2010
Loading...

Share This Page