Reading and displaying data from a .txt file

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

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

10条回答
  •  感动是毒
    2020-11-27 15:59

    I love this piece of code, use it to load a file into one String:

    File file = new File("/my/location");
    String contents = new Scanner(file).useDelimiter("\\Z").next();
    

提交回复
热议问题