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://www.codercto.com/courses/l/12.html

查看所有标签

C++ Concurrency in Action

C++ Concurrency in Action

Anthony Williams / Manning Publications / 2012-2-28 / USD 69.99

HIGHLIGHT C++ Concurrency in Action is the first book to market to show how to take advantage of the new C++ Standard and how to write robust multi-threaded applications in C++. DESCRIPTION With ......一起来看看 《C++ Concurrency in Action》 这本书的介绍吧!

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

在线图片转Base64编码工具

Markdown 在线编辑器
Markdown 在线编辑器

Markdown 在线编辑器

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具