• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

RandomAccessFile

 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Are you okay? You look a little big. Maybe this tiny ad will help:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic