Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

808 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