Java 实例 - 读取文件内容

 


 

 1 package com.guyu.day0914;
 2 
 3 import java.io.BufferedReader;
 4 import java.io.FileReader;
 5 import java.io.IOException;
 6 
 7 /**
 8  * @Author: Fred
 9  * @Date: 2020/9/14 10:58
10  */
11 public class Demo01 {
12     public static void main(String[] args) {
13 
14         //使用 readLine() 方法来读取文件 guyu.txt 内容,
15         //其中 guyu.txt 文件内容为:您好 故屿!
16         try {
17             BufferedReader in = new BufferedReader(new FileReader("guyu.txt"));
18              String str;
19             while ((str = in.readLine()) != null) {
20             System.out.println(str);
21         }
22         System.out.println(str);
23         } catch (IOException e) {
24             //Nothing
25         }
26     }
27 }

 

 


 

Note:
欢迎点赞,留言,转载请在文章页面明显位置给出原文链接
知者,感谢您在茫茫人海中阅读了我的文章
没有个性 哪来的签名!
详情请关注点我
持续更新中

© 2020 09 - Guyu.com | 【版权所有 侵权必究】

posted @ 2020-09-15 09:10  故屿γ  阅读(188)  评论(0)    收藏  举报