943,390 Members | Top Members by Rank

Ad:
  • Java Discussion Thread
  • Unsolved
  • Views: 28119
  • Java RSS
Jan 7th, 2005
0

to delete contents of a text file

Expand Post »
hi my project involves ping multiple comps simultaneously
to do that i am storing results of each comp in its designated text file
for that at startup i have to clear its contents i want to know how to do that in java???????
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
smartdetect is offline Offline
22 posts
since Aug 2004
Jan 7th, 2005
0

Re: to delete contents of a text file

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.
Reputation Points: 11
Solved Threads: 1
Junior Poster in Training
jerbo is offline Offline
84 posts
since Sep 2004
Jan 8th, 2005
0

Re: to delete contents of a text file

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.
Team Colleague
Reputation Points: 1658
Solved Threads: 331
duckman
jwenting is offline Offline
7,719 posts
since Nov 2004
Jan 8th, 2005
0

Re: to delete contents of a text file

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
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Java Forum Timeline: Sorting arrays and then checking for duplicate characters
Next Thread in Java Forum Timeline: message applet failed





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC