Reading a specific line from a text file in Java

后端 未结 9 749
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 07:34

Is there any method to read a specific line from a text file ? In the API or Apache Commons. Something like :

String readLine(File file, int lineNumber)
         


        
9条回答
  •  执笔经年
    2020-11-27 08:15

    If the lines you were reading were all the same length, then a calculation might be useful.

    But in the situation when the lines are different lengths, I don't think there's an alternative to reading them one at a time until the line count is correct.

提交回复
热议问题