Is there a way to do this?
I’m coding a program that has to iterate for a very long time, and while doing so it is supposed to write to file. I want to close the stream as soon as I terminate the program manually and by doing so, avoid the risk of loosing data because of the unclosed stream. There should be a way of doing this with exception handling, but I’m not sure. Any kind of suggestion is very appreciated!
Thank you
I found a way! I lost so much time with this, without noticing that streams are automatically closed when the program terminates…
Data hadn’t been written because I wasn’t using the flush() method after the write() method, like this:
Thank you all for your help