java - Issue reading a file path from a Properties file -
i'm working on swing app allow users view sets of (mostly locally-stored) files. i'm able store lists of files (among other preferences) text in properties files when try pull file values out, using
myproperties.getproperty("file")
it discards some of '\'s in text. confirmed writing properties files this:
myprintwriter.println("file = " + myfile.tostring().replaceall("\\\\", "/"))
or this:
myprintwriter.println("file = " + myfile.tostring().replaceall("\\\\", "\\\\\\\\"))
would allow getproperty() work more expected didn't having convert data java-specific format without explanation in api decided write on stack overflow.
but when got point in post started feeling embarrassed; post on stack overflow without consulting java source code java.util.properties (distributed jdk). found javadoc comments properties.load() indicate design decision which, example, allows properties values contain line breaks. guess i'll writing properties files in xml if find need language-independence.
epilogue: first post on stack overflow , i've answered own question i've decided post anyhow in hopes person (or, perhaps, artificial natural-language-processing-intelligence) may find useful (or illuminating). also, i'm curious ideas or suggestions people might post in reply. tl;dr? reading!
you use properties.store() write out properties. store() documented writing properties in format load() read, take care of massaging needs done.
Comments
Post a Comment