| | |
to delete contents of a text file
![]() |
•
•
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: 7
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 |
911 actionlistener addressbook android api append applet application array arrays automation binary blackberry block bluetooth character chat class client code component consumer csv database desktop developmenthelp eclipse error fractal ftp game givemetehcodez graphics gui html ide image integer j2me j2seprojects japplet java javaarraylist javac javaee javaprojects jni jpanel julia lego linked linux list loops mac map method methods mobile netbeans newbie number objects online oriented panel printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server set singleton sms sort sql string swing test textfields threads time title tree tutorial-sample ubuntu update windows working






