• Post Reply Bookmark Topic Watch Topic
  • New Topic

Update Text File  RSS feed

 
meena latha
Ranch Hand
Posts: 219
  • Mark post as helpful
  • send pies
  • 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 ]
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • 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.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!