Link to home
Start Free TrialLog in
Avatar of rayskelton
rayskelton

asked on

How to read to a file position using FileInputStream and alter a specific record.

I am using FileInputStream to find a position in a file and would like to edit a perticular record when all criteria is met. How do I change from a FileInputStream to a FileOutputStream without loosing my file pointer?
 
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jimmack
jimmack

I don't think you can do this without reading from the input and writing to the output until you hit the record you want, then writing the new record and finally continuing reading/writing (ie. effectively copying the file).

If you want to jump in to the middle of a file and do editing, you should probably be using a RandomAccessFile.
Hee hee ;-)