Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

File I/O

 
Brendan Kennedy
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
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.
Reading:

Writing:

How do I make sure these things happen one after the other instead of at the same time?
Thanks,
Brendan
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the symptoms you're getting?
Have you tried explictly flushing the first stream before closing it?
You got threads somewhere in there?
-Barry
 
Brendan Kennedy
Ranch Hand
Posts: 65
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply
The exception is as follows:-
java.io.FileNotFoundException: 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.
Brendan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic