The moose likes Java in General and the fly likes File I/O Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "File I/O" Watch "File I/O" New topic

File I/O

Brendan Kennedy
Ranch Hand

Joined: May 02, 2001
Posts: 65
I'm reading and writing to the same file in one class. It seems that the file input stream is not closed before i open the file output stream even though I do these things at different times in different methods in my code and always 'finally' close the streams after use.


How do I make sure these things happen one after the other instead of at the same time?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
What are the symptoms you're getting?
Have you tried explictly flushing the first stream before closing it?
You got threads somewhere in there?

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Brendan Kennedy
Ranch Hand

Joined: May 02, 2001
Posts: 65
Thanks for the reply
The exception is as follows:- keno.xml (Permission denied)
I can write to a second file in the second part with no problems.
I get an error on compilation if I try to flush a fileinputstream and flushing the outputstream doesn't seem to do anything.
It's possible the marshal/unmarshal method is threaded.. I'll have to research it.
I agree. Here's the link:
subject: File I/O
jQuery in Action, 3rd edition