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

read all the data, change what you want to change, and write it (not appending) to the file

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????

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.