java: how to use bufferedreader to read specific line

后端 未结 3 514
情话喂你
情话喂你 2020-12-16 06:12

Lets say I have a text file called: data.txt (contains 2000 lines)

How do I read given specific line from: 500-1500 and then 1500-2000 and display the output of spec

3条回答
  •  佛祖请我去吃肉
    2020-12-16 07:05

    The better way is to use BufferedReader. If you want to read line 32 for example:

    for(int x = 0; x < 32; x++){
        buf.readLine();
    }
    lineThreeTwo = buf.readLine();
    

    Now in String lineThreeTwo you have stored line 32.

提交回复
热议问题