• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Search using FileChannel

 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently, via a singleton class, I use one FileInputStream for accessing my data file. I plan to implement my criteria find method by loading all the records into a cache who's scope is local to the criteria find method. Because I don't want to fool around with the main FileInputStream's position. I create a FileInputStream that is local to the criteria find method. Does this seem okay? Or is there some reason why I shouldn't create a FileInputStream local to the method?
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems ok to me. You run the risk of dirty reads, but that's always a risk, unless you lock before reading. the subject of your post indicated that you had a question about FileChannels? Do you know how to use them for this purpose?
M, author
The Sun Certified Java Developer Exam with J2SE 1.4
 
Ronnie Phelps
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After writing the subject I decided to use a more Generic name since FileChannel's are fairly new. But I do understand the API now. Thanks again Max.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Channels are a great way to read the data.
I learned them from Max's book.
Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic