Solved

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

Posted on 2003-12-12
4
295 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
  • 2
  • 2
4 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 125 total points
Comment Utility
use a randomaccessfile instead...
0
 
LVL 15

Expert Comment

by:jimmack
Comment Utility
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
Comment Utility
Hee hee ;-)
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
;-)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
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 the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now