Solved

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

Posted on 2003-12-12
4
324 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

828 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