• Post Reply Bookmark Topic Watch Topic
  • New Topic

Reading a text file

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I have a text file with several thousand lines of data.
I know I can read each line one at a time using..

But I'd like to be able to just read in line 2000, for example..
So that I can do a binary search on the data.

Is this possible?
Thanks for any help
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by colin shuker:

But I'd like to be able to just read in line 2000, for example..
So that I can do a binary search on the data.
Is this possible?


The api directly does not provide a way to read the data at a line number.
Although you can make a RandomAccessFile work the way you want but it needs some amount of work.
This article will give you an insight.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!