| | |
to delete contents of a text file
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2004
Posts: 84
Reputation:
Solved Threads: 1
Two things.
One, show us first what you have. Then we can assist in helping you
Two, this forum is for assistance, not free code. If you want to learn how to do it in Java, show some effort first. I work for a living and do research accordingly. I read the books, search the web for code libraries, etc. It's not that hard if you put forth the effort.
One, show us first what you have. Then we can assist in helping you
Two, this forum is for assistance, not free code. If you want to learn how to do it in Java, show some effort first. I work for a living and do research accordingly. I read the books, search the web for code libraries, etc. It's not that hard if you put forth the effort.
hmm, my earlier response seems to have been lost in the depths of the web 
Let's try again: the class File (which you use to open and handle disk files as well as in-memory files) has an option to delete a file if it exists and you open it with write access.
If you use that you need to do nothing else.
More details in the API docs.

Let's try again: the class File (which you use to open and handle disk files as well as in-memory files) has an option to delete a file if it exists and you open it with write access.
If you use that you need to do nothing else.
More details in the API docs.
•
•
Join Date: Jun 2004
Posts: 609
Reputation:
Solved Threads: 8
Hi everyone,
You could have a hidden textarea and then read the file into textarea, clear the textarea and then write it back out to the same file thus all the contents are actually cleared. Actually from what i read i think that it is possible for you to use the Java StringBuffer class as you need to clear on startup thus eleminating the use of using any kind of files.
I hope this helps you
Richard West
You could have a hidden textarea and then read the file into textarea, clear the textarea and then write it back out to the same file thus all the contents are actually cleared. Actually from what i read i think that it is possible for you to use the Java StringBuffer class as you need to clear on startup thus eleminating the use of using any kind of files.
I hope this helps you
Richard West
![]() |
Similar Threads
- Delete last line from text file (Java)
- how to delete the last line of the text file using c# (ASP.NET)
- delete a list in text file (Python)
- Code Snippet: delete a line from a text file (C++)
- read-delete lines from a text file (PHP)
- Insert Contents Of Text File Into Database (ASP.NET)
- read from database and writing the contents into a text file (C)
- to delete contents of a text file (Java)
Other Threads in the Java Forum
- Previous Thread: Sorting arrays and then checking for duplicate characters
- Next Thread: message applet failed
| Thread Tools | Search this Thread |
Tag cloud for Java
addressbook android api apple applet application arguments array arrays automation binary bluetooth button calculator chat class classes client code columns component converter database draw eclipse error errors event exception file fractal ftp game givemetehcodez graphics gridlayout gui helpwithhomework html ide image inetaddress input integer j2me japplet java javaprojects jme jmf jni jpanel julia link linux list loop map method methods midlethttpconnection mobile netbeans newbie number objects openjavafx oracle php print problem program programming project projects recursion rim scanner screen server set signing size smart sms socket sort sql storm string support swing test threads time tree unlimited variablebinding webservices windows






