I've a text file which I'll be using it to write content.. But every time before I write something to the file, I wish to clear the content without deleting the file..
How would I achieve the above? Any suggestions?
If you're working at the command line and need to quickly empty the contents of a file, you can do so by throwing a greater than symbol and a space in front of the filename in question.
delete() method. In Java, we can delete a file by using the File. delete() method of File class. The delete() method deletes the file or directory denoted by the abstract pathname.
With text files you can simply set it to an empty string.
file.text = ''
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With