randomaccessfile versus bufferedreader

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jyohere
    New Member
    • Apr 2007
    • 73

    randomaccessfile versus bufferedreader

    I want to know which one will be faster randomAccessFil e or Bufferedeader. I am reading a file about 18 MB. For that using randomAccessFil e i will read from the beginning of the file the first time and i will get the position of file pointer depending on the line's data and after that i will start reading from the position of file pointer. this will happen for each call of one method that i wrote..... initially i used BufferedReader but it was slow.....so i tried randomAccessFil e..but i feel its very slow the first time it goes thru the file......there is a method mark in BufferedReader. ...but for that the parameter is the number of characters that i will read after that position.But i don't know the number of characters..... .so,i am really confused wat to do...My r/qment is: I want to read the file fully only once when my method is called.....and then after i will read from the position i have marked....pls help... i want to read the file faster
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    If you're talking Readers you're talking text files. 18MB isn't that much so I'd
    suggest a simple List<String> that contains all the lines of the file. If that is too
    slow for your purposes, please elaborate a bit on *what* exactly you want to do
    with that data.

    I vaguely remember about another thread of yours dealing with the very same issue.

    kind regards,

    Jos

    Comment

    • jyohere
      New Member
      • Apr 2007
      • 73

      #3
      I have a file that gets appended with data for every 15 minutes.....ini tially when i read the file with bufferedReader when the file is small it works fast...but as the file size grows bigger, the execution goes slow.....

      Comment

      Working...