I'm writing a data to a text file using PrintWriter.
Now if user closes the program only half of data will be wrote inside it.
Now if user closes the program only half of data will be wrote inside it.
How to know the instance of closing of program and write all the data completely to the text file before closing the program?
1