How to read a specific line using the specific line number from a file in Java?

file-io, java

Solution

Unless you have previous knowledge about the lines in the file, there's no way to directly access the 32nd line without reading the 31 previous lines.

That's true for all languages and all modern file systems.

So effectively you'll simply read lines until you've found the 32nd one.

Problem

In Java, is there any method to read a particular line from a file? For example, read line 32 or any other line number.

Original source

Related problems