Java 实例 - 读取文件内容

Java 教程 · 2019-02-10 20:12:27

以下实例演示了使用 readLine() 方法来读取文件 test.log 内容,其中 test.log 文件内容为:

码农教程
www.codercto.com

java 代码如下:

Main.java 文件

import java.io.*; public class Main { public static void main(String[] args) { try { BufferedReader in = new BufferedReader(new FileReader("test.log")); String str; while ((str = in.readLine()) != null) { System.out.println(str); } System.out.println(str); } catch (IOException e) { } } }

以上代码运行输出结果为:

码农教程
www.codercto.com
null

点击查看所有 Java 教程 文章: https://codercto.com/courses/l/12.html

查看所有标签

Tales from Facebook

Tales from Facebook

Daniel Miller / Polity Press / 2011-4-1 / GBP 55.00

Facebook is now used by nearly 500 million people throughout the world, many of whom spend several hours a day on this site. Once the preserve of youth, the largest increase in usage today is amongst ......一起来看看 《Tales from Facebook》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

XML、JSON 在线转换
XML、JSON 在线转换

在线XML、JSON转换工具