Note that there are some explanatory texts on larger screens.

plurals
  1. POIssue reading a file path from a Properties file
    primarykey
    data
    text
    <p>I'm working on a swing app that will allow users to view sets of (mostly locally-stored) files. I'm able to store lists of files (among other preferences) as text in Properties files but when I try to pull file values back out, using</p> <p><code>myProperties.getProperty("File")</code></p> <p>it discards <em>some</em> of the '\'s that are in the text. I confirmed that writing to the Properties files like this:</p> <p><code>myPrintWriter.println("File = " + myFile.toString().replaceAll("\\\\", "/"))</code></p> <p>or this:</p> <p><code>myPrintWriter.println("File = " + myFile.toString().replaceAll("\\\\", "\\\\\\\\"))</code></p> <p>would allow <code>getProperty()</code> to work more like I expected but I didn't like having to convert my data to a Java-specific format without an explanation in the API so I decided to write it up on Stack Overflow.</p> <hr> <p>But when I got to this point in my post started feeling embarrassed; I was about to post on Stack Overflow without even consulting the Java source code for <code>java.util.Properties</code> (distributed with the JDK). I found that the Javadoc comments for <code>Properties.load()</code> indicate this was a design decision which, for example, allows Properties values to contain line breaks. I guess I'll look into writing my Properties files in XML if I find that I need that language-independence.</p> <hr> <p>Epilogue: So this is my first post on Stack Overflow and I've answered my own question but I've decided to post it anyhow in the hopes some person (or, perhaps, some artificial natural-language-processing-intelligence) may find it useful (or illuminating). Also, I'm curious as to any ideas or suggestions people might post in reply. TL;DR? Thanks for reading!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload