The Artima Developer Community
Sponsored Link

Java Answers Forum
how should i append data to file by overwriting the one's already existing?

6 replies on 1 page. Most recent reply: Aug 19, 2005 1:31 AM by Kondwani Mkandawire

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
nabakumar

Posts: 23
Nickname: nkmeitei
Registered: Jun, 2005

how should i append data to file by overwriting the one's already existing? Posted: Aug 16, 2005 9:23 PM
Reply to this message Reply
Advertisement
hello
everybody

I want to overwrite the names which are already existing and to append the new names in a file. can anybody plz help out.
if i use the FileWriter(Fname,boolean true),
it appends the even the ones which are existing, i want to append the new ones only.

regards
nab


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how should i append data to file by overwriting the one's already exist Posted: Aug 16, 2005 11:37 PM
Reply to this message Reply
No clue what you're talking about.

Please give an example.

Possibly if you will want to search the names after
having stuck them in a temp Storage (A Collection
probably), but as I said, I'm unclear on what you
would like to do.

Give a more detailed example

nabakumar

Posts: 23
Nickname: nkmeitei
Registered: Jun, 2005

Re: how should i append data to file by overwriting the one's already exist Posted: Aug 17, 2005 2:16 AM
Reply to this message Reply
let me explain you

I need to dump the output of my application in a file.
only the output which are true need to be dumped in the file.
Each time i run the apllication ,i get some of the results which were previously false as true ,my requirement is to overwrite the existing ouput and append the new true output.

regards
nab

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how should i append data to file by overwriting the one's already exist Posted: Aug 17, 2005 2:55 AM
Reply to this message Reply
I'm really sorry but honestly the language barrier seems to be
a bit of a problem.

Anyways, I'll respond to what I think you are asking.

Use a HashMap (see java api HashMap) to collect
data from your current file:

In the hash_map key="word", value=true if in file;
make the hash_map global;
Next time you run your out put check
if current_word exists in hash_map
if - above is true
don't add it to hash_map
else // it is false
add to hash_map

write the whole hash_map to the file
(simply overwrite and it will include everything that is
was previously on file and is currently on file (the overwrite will ensure that there are no duplications)

nabakumar

Posts: 23
Nickname: nkmeitei
Registered: Jun, 2005

Re: how should i append data to file by overwriting the one's already exist Posted: Aug 17, 2005 3:52 AM
Reply to this message Reply
Thanks alot for ur reply.

its working!

Jeroen Wenting

Posts: 88
Nickname: jwenting
Registered: Mar, 2004

Re: how should i append data to file by overwriting the one's already exist Posted: Aug 19, 2005 12:42 AM
Reply to this message Reply
Why do people fire off the exact same question (just copy/paste both text and title) on multiple forums?

Most of us visit many places on the web, it gets extremely tiring seeing a question answered here (for example) you just answered elsewhere...

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: how should i append data to file by overwriting the one's already exist Posted: Aug 19, 2005 1:31 AM
Reply to this message Reply
Seems to me that from the torrent of other responses you have
given to various posts that you may have woken up on the wrong
side of the bed. The other posts to an extent seem to merit
the harsh and sarcastic tone, but in all honesty I don't see
why you'd come crashing down on this guy.

If you're doing research for instance, you seek out several
sources don't you? I rely solely on Artima because of its
ease of use, but in all honesty if my tasks din't require
such tight deadlines I'd probably seek out several other
sites to solutions for the problems I have.

You might find that one Intermediate Java developer (competent
enough to respond to minor issues) might be a dedicated Java
World user whilst another (like myself) might be an Artima
user. So why loose out on the possibility of the javaworld
response if the Artima response is either taking a while?

Man, take a chill pill!!

Flat View: This topic has 6 replies on 1 page
Topic: UML CASE Tool - Integrate with the Most Popular IDEs Previous Topic   Next Topic Topic: Eclipse Bug??  Linux Problem??

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use