2 posts
Posted 17 January 2015 - 06:35 AM
When I simply open and write in a text file:
u = fs.open("Hello", "w")
u.write("Hello")
and then I edit the file nothing is written in it, the text will only appear after I reboot the computer…
So is there a fix, because this is really annoying…
Thanks
8543 posts
Posted 17 January 2015 - 10:14 AM
You're supposed to close file handles after you're done using them. Throw this after the write call:
u.close()
That will close the file handle and write your changes to the actual file.
808 posts
Posted 17 January 2015 - 11:51 AM
Also, flushing writes unwritten data to disk. Closing says "I'm done, I have no more to write. Put all my changes on disk and clean up now." This is required. But flushing just puts the changes on disk, without doing the closing, so that you can continue to write to the file after flushing.
u.writeLine("Hello")
u.flush()
u.writeLine("Hello again")
The resulting file will only have the "Hello" line, because that line was flushed, and the second line was not, since the handle was never closed or flushed after its writeLine call.
2 posts
Posted 17 January 2015 - 07:30 PM
Thanks a lot for the quick respond !