I want to access the file using specific line number without reading whole file.Is it possible in java?
Asked
Active
Viewed 112 times
-2
-
You can use a LineNumberReader (a child of BufferedReader to read the file. – NomadMaker Jul 06 '20 at 19:08
1 Answers
1
It's not possible in any language unless the file has some sort of indexing feature.
Unless you know where the lines are you need to scan the file and count them. If you need to access the same file a lot you could always scan it once and build an index - you still need to do the first pass through though.

Tim B
- 40,716
- 16
- 83
- 128