• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Update Text File

 
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all.

I am using text file to store all my data's that are to be displayed in my jsp.I am reading my text file data using the below code.


And inserting the values into a list.


here collect is a java class with getter and setter methods.

After this i am validating my data and if there is a error .
The error data is displayed in a text box where we can correct the value .

Now my problem is how do i save the corrected value to my text file.

For example,my text File has
23;1;North ;100
22;3;South;200
21;4;East;600
20;5;Weet;900

My fourth list has wrongly spelled name.
So this will appear in the text box and after correcting it how do i save this in text file.
The error date will appear in a jsp page with a save button in it.
This save button will call a method in Action Class.
I dont know what should i do in that action class to save the corrected value to the text file.

Any hit or clue or any help will be really appreciated.
Thanks
[ January 04, 2006: Message edited by: ramya jai ]
 
Ranch Hand
Posts: 2412
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because of the static nature of a text file, I think the only way to accomplish what you want is to read the entire file into memory, make the changes and write the file back. I would suggest doing this in a synchronized method.
 
(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 often toss out this series of steps borrowed from an IBM mainframe timeshare system:

If somebody kicks the plug out of the wall at any time in there you still have a safe copy of the old and/or new data.
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic