inside the properties there are a few keys and "test" is one of them, if I set fout to true, it will append the whole properties file below without the removed key. But if I don't set fout to true, all the keys and values wil be removed. Actually I want the original file to be updated. Is it I need to use a workaround, say, store it in a different fout file after removing the key, and then delete the fin file, then rename the fout file to the fin file?
inside the properties there are a few keys and "test" is one of them, if I set fout to true, it will append the whole properties file below without the removed key. But if I don't set fout to true, all the keys and values wil be removed.
What do you mean by "set fout to true"? fout is an outputstream, not a boolean variable.
BTW, the properties store() method, just writes the basic properties out to the stream. If the original property file had an ordering, comments, and extra line spaces for readability, they will all be gone. In other words, if you store(), don't expect the property file to be nicely formatted anymore.
I would strongly advise you don't try to have an InputStream and and OutputStream for the same file at the same time. Depending on the operating system, it may throw an error, or you may get some very strange results. Keep these actions separate: open an input stream, read it, and close it. Then open an output stream, write to it, and close it.
I assume by "set fout to true" you're talking about the FileOutputStream constructor that takes a booolean, for appending. You don't want to append here; you want to write a new file.
"I'm not back." - Bill Harding, Twister
Joined: Nov 10, 2005
Hi Henry, Tim is right about the boolean for fout, I mean the append argument for the constructor, sorry about the lack of info.
Thanks guys, I think I'll use a workaround to get what I want. [ December 22, 2006: Message edited by: vivien siu ]