?
Solved

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

Posted on 2003-12-12
4
Medium Priority
?
342 Views
Last Modified: 2008-03-06
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
Comment
Question by:rayskelton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 500 total points
ID: 9927798
use a randomaccessfile instead...
0
 
LVL 15

Expert Comment

by:jimmack
ID: 9927804
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
 
LVL 15

Expert Comment

by:jimmack
ID: 9927805
Hee hee ;-)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 9927809
;-)
0

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question