Make BufferedReader start from the middle of a .txt file rather than the beginning?

前端 未结 3 1732
清歌不尽
清歌不尽 2021-01-18 04:16

I have a LONG .txt file that contains almost 6000 lines! Sometimes I need to retrieve the info. in line 5000. Is it possible to start reading from line 5000 rather than sta

3条回答
  •  逝去的感伤
    2021-01-18 04:38

    Whether 6000 lines are long or not depends on the average line length. Even with 100 characters per line, this is not really long.

    Nevertheless, you can read from line 5000 if you know where line 5000 starts. Unfortunately, most of the time you'll have to read lines 1 through 4999 to find that out.

提交回复
热议问题