Link to home
Create AccountLog in
Avatar of ang3lus
ang3lus

asked on

java file input and output handling

Hi
can someone help to deal with file
i have file that has format:
E008,Michelle,1980, manager, 17000
E008,George,1970, manager, 10600
E008,Jonathan,1940, manager, 25000

i don't have any problem with reading or writing to file

my question is:
there is a quick way to update specific element in file like salary
How i can while i am reading from file change element from specific line like salary
for example
E008,Michelle,1980, manager, 17000
E008,Michelle,1980, manager, 0

thanks
SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
You cannot update one line or one item in the file,
you need to read the whole file and re-write it to a new
plcae and while doing it you can parse the contents get to the element you need and replace it.
ASKER CERTIFIED SOLUTION
Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Avatar of ang3lus
ang3lus

ASKER

thanks
Just a word of caution - I'm sure you know but just in case: when running and especially debugging this sort of programs
in real life certainly make sure that you have copies of all your files - there's nothing easier to do thhan to lose
your the whole file with one wrong operator.