to delete contents of a text file

Reply

Join Date: Aug 2004
Posts: 22
Reputation: smartdetect is an unknown quantity at this point 
Solved Threads: 0
smartdetect smartdetect is offline Offline
Newbie Poster

to delete contents of a text file

 
0
  #1
Jan 7th, 2005
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???????
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 84
Reputation: jerbo is an unknown quantity at this point 
Solved Threads: 1
jerbo jerbo is offline Offline
Junior Poster in Training

Re: to delete contents of a text file

 
0
  #2
Jan 7th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 213
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: to delete contents of a text file

 
0
  #3
Jan 8th, 2005
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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: to delete contents of a text file

 
0
  #4
Jan 8th, 2005
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC