Skip to content

Latest commit

 

History

History
60 lines (35 loc) · 1.74 KB

File metadata and controls

60 lines (35 loc) · 1.74 KB

Java I/O 流

原文: https://www.programiz.com/java-programming/io-streams

在本教程中,我们将学习 Java 输入/输出流及其类型。

在 Java 中,流是从源读取并写入目的地的数据序列。

输入流用于从源读取数据。 并且,输出流用于将数据写入目的地。

class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!"); 
    }
} 

例如,在我们的第一个 HelloWorld 示例中,我们使用了System.out打印字符串。 此处,System.out是一种输出流。

同样,也有输入流可以接受输入。

Input stream reads data from source to program and output stream writes file from program to destination

我们将在后面的教程中详细了解输入流和输出流。


流的类型

根据流包含的数据,可以将其分类为:

  • 字节流
  • 字符流

字节流

字节流用于读取和写入单个字节(8 位)的数据。

所有字节流类均从称为InputStreamOutputStream的基本抽象类派生。

要了解更多信息,请访问


字符流

字符流用于读取和写入单个数据字符。

所有字符流类均从基本抽象类ReaderWriter派生。

要了解更多信息,请访问: