| Author |
Update Text File
|
meena latha
Ranch Hand
Joined: Jan 24, 2005
Posts: 219
|
|
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
Joined: Feb 07, 2005
Posts: 2341
|
|
|
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
Joined: Jan 29, 2003
Posts: 8791
|
|
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.
|
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
|
 |
 |
|
|
subject: Update Text File
|
|
|