Once the stream is closed, subsequent calls to write () or flush () will throw an IOException. However, closing a previously closed stream is not affected.
while(incomingdata == true){ writer.write(data) } writer.close()
You do not need to rinse every time. since calling close() will clear the data first before closing the stream.
Updated for
The file I created must be saved. Why do they close it to update the timestamp. That when the file is synchronized live.
Use it like this:
while(incomingdata == true){ writer.append(data); writer.flush(); } writer.close();
source share