IO-STEAM-基础

定义

先来看java中对于IO中STREAM的定义

An I/O Stream represents an input source or an output destination. A stream can represent many different kinds of sources and destinations, including disk files, devices, other programs, and memory arrays.

Stream 是建立在物理资源上的,input source or output destination.

Streams support many different kinds of data, including simple bytes, primitive data types, localized characters, and objects. Some streams simply pass on data; others manipulate and transform the data in useful ways.

Stream 支持不同数据种类。BYTE, CHARACTER, PRIMITIVE DATA TYPES, OBJECTS. 等

输入流
IO-STEAM-基础_第1张图片

输出流
IO-STEAM-基础_第2张图片

JAVA中Stream类的设计

所以Stream有两个属性,【目标资源】和【数据种类】,根据这两个属性可以对JAVA-SE中STREAM分类。

JAVA-SE中类的设计是,先根据 【数据种类】写一个父类,比如 InputStream。然后根据【目标资源】的不同写一个具体的实现类,比如 FileInputStream 实现对文件的字节读写。

你可能感兴趣的:(IO)