Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RandomAccessFile

 
donal horgan
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Folks,

Quick question -- I am on the URLybird project.

However I have hit a brick wall.
I am currently working on the localised version as opposed to networked.
Basically -- I have my main in my GUI which immediately initialises my Data.java constructor.
This class contains my methods such as FindByCriteria etc.

Basically -- where do I open and close my file in the Data class given that my methods(findByCriteria etc.) have to be able to see the file?
Obviously I can't have my methods in the constructor.
But when my methods are outside the constructor it can't see the file -- even if i don't close the file -- as the methods are outside the try-catch of the IOException.

I feel I'm in a catch 22.
Surely I don't open and close the file within each method?
I'm assuming the file need only be opened once.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Donal

I'm assuming the file need only be opened once.


That' realy depends on your decisions/architecture/mechanism.
If you gonna cash the information them you only read the data file once but there are also other solutions.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic