[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: RandomAccessFile

Hi chetu,

you need to do the processing you want, in a different way...

Read lines from the passwd file(using readLine), until you reach the
line you want to change, and write those lines verbatim to another
temporary file. Do the required changes in the line in which you want to
change the password, write that line to the temp file, followed by the
rest of the lines. Later make the remove the original passwd file, and
rename your temp file as the passwd file (doing this as a part of
synchronized code, if needed).

Chetan Gopal Kashinath wrote:

> since i am able to replace chars only... i can successfully change the
> password only if the old and new passwords are of the same length..
> i may later on want to insert new lines and delete lines
> how can i do this ???

> - chetu

"In matrimony, to hesitate is sometimes to be saved."
-- Butler