0

hi can anyone give me a suggestion as to how i could replace data in dat file. the problem is that if i put the data into a string buffer and call replace it will not change the data in the file but i need that to hapen and the user to just define which entry he wishes to change.can i get help as to how this need to be done.thanks

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by stultuske
0

hi can you please give me an example code. According to what you have said lets say my dat file contains the following

CodeNameAddressPhone
111Smith3bugsSt112233
222John4northSt223344
333Vince6southSt445577

lets say i have to change add for john having code 222.
i will scroll through to read the data untill i reach record code 222.
read first utf than my cursor reaches the point from where i have to change.

if i just write to the file possibilities are i might replace or overite some data which i dont want to right???
for eg lets say i had to change the address to "johnson and johnson st"
since this string literal is longer than "4 north st" its gona also overite the phone.

now how do i go about avoiding that????

0

by splitting up the data in seperate parts.
I recommend using a StringTokenizer

your dat file would become something like:

Code*Name*Address*Phone
111*Smith*3BugStr*112233

if here you need to change 3BugStr to 3LindenRoad, you 'll get


Code*Name*Address*Phone
111*Smith*3LindenRoad*112233

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.