JAVA 3 You use a PrintWriter to create a text file but when
JAVA
3. You use a PrintWriter to create a text file, but when you check it it is empty even though you printed several lines. What went wrong? 4. How do you append lines to a text file?
Solution
There can be various reasons because of which Printwriter can create an empty file even after writing data to the file in java.
Common reasons being

