Reading and displaying data from a .txt file

后端 未结 10 948
北海茫月
北海茫月 2020-11-27 15:41

How do you read and display data from .txt files?

10条回答
  •  眼角桃花
    2020-11-27 15:54

    BufferedReader in = new BufferedReader(new FileReader(""));
    

    Then, you can use in.readLine(); to read a single line at a time. To read until the end, write a while loop as such:

    String line;
    while((line = in.readLine()) != null)
    {
        System.out.println(line);
    }
    in.close();
    

提交回复
热议问题