how to delete the content of text file without deleting itself

Just print an empty string into the file:

PrintWriter writer = new PrintWriter(file);
writer.print("");
writer.close();

Leave a Comment