• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Delete from data..

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi to all..
i need to know how to delete data stored in TextFile.. the data are display in JTextField which can be deleted by clicking a "Delete" button.. Any kind soul out there can help.. would say a big thank u to whoever.. urgently..
Regards
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I get your requirement. Maybe it's:
* There is a text file with a bunch of strings / lines.
* The user enters a string in the UI.
* You want to remove the user's string from the file?
You can't really update a text file in place. You pretty much have to read it modify the content and rewrite it. You can read it all into memory at once or read-modify-write a line at a time. Either way, here's a scheme I like:
* read original
* write temp
* rename original to backup
* rename temp to original
* erase backup
That gives you a safe copy of the file at all times just in case your program crashes in mid-flight.
Does that help?
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for replying..
Mm.. i guess i really need ur help for i have left no one to consult, and i'm new to textfile..
Can i just explain to u what roughly i'm doin, to let u have a clear view..
i'm doin a Calendar with Schedule
And there are JTextField for the schedule to be displayed.. And from there, user can edit & delete in the JTextField.. the problem i have now is that, no matter what date was selected, to display the schedule and then edit will be overwrite to the first position of the TextField.. And prevent it from displaying again.. Therefore i need to know where my mistake is in the code. By the way, i'm using a JDK1.3.1.. So there may be some method that i can't use.. Pls point out my mistake and corect me.. i have been trying this a couple of days, & my deadline is tomorrow.. Can u kindly pls help me.. A big Thanks to u..
 
Freya Tan
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
this is very impt to me.. Pls reply asap.. pls.. Thanks u..
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does 'asap' mean?
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
asap = as soon as possible.
Generally, the moderators discourage people posting questions as a matter of 'urgency.' We're an all-volunteer site focussed on providing an easy-to-use interface and a welcoming air. No one gets paid and no one earns 'points' for answering questions -- just the satisfaction of helping other people out. Possibly we do it because someone else helped us out before and paying it forward is a good thing.
No one's obliged to answer posted questions -- although it does promote the spirit of the place. I can't see any post here being more important than the next, so marking something "urgent" doesn't make much sense.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic