• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 351
  • Last Modified:

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?
 
0
rayskelton
Asked:
rayskelton
  • 2
  • 2
1 Solution
 
TimYatesCommented:
use a randomaccessfile instead...
0
 
jimmackCommented:
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.
0
 
jimmackCommented:
Hee hee ;-)
0
 
TimYatesCommented:
;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now