Reading and displaying data from a .txt file

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

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

10条回答
  •  北荒
    北荒 (楼主)
    2020-11-27 15:49

    To read lines from .txt file with encoding UTF-8:

    File krokiPath = new File("Records\Record");
    BufferedReader in = new BufferedReader(
            new InputStreamReader(new FileInputStream(krokiPath), "UTF8"));
    
    while((r = in.readLine()) != null) {
        System.out.println(r);
    }
    in.close();
    

提交回复
热议问题