read lines in txt file [java]

前端 未结 2 2065
鱼传尺愫
鱼传尺愫 2020-12-18 12:22

I\'ll try to be as clear as possible but pardon me if my question is not perfect. I have a txt file with several lines of data. example:

123 ralph bose 20000 200 1 2

2条回答
  •  粉色の甜心
    2020-12-18 13:13

    There are lots of ways to read an entire line at a time; Scanner is probably easiest:

    final Scanner s = new Scanner(yourFile);
    while(s.hasNextLine()) {
        final String line = s.nextLine();
        YourClass.processLine(line);
    }
    

提交回复
热议问题