Music of Java byte file, the basics of IO stream and procedures

Hi myself, a small music again, we need to give today's technology to send the article is focused on Java knowledge -IO flow.

Let's look at the mind map IO stream it.

A, File

In Java, Everything is Object! So in the file, is no exception! In Java, you can use the File class to represent a link to the file on your hard disk! ! ! note:

1, File represent only a link, the file may exist or may not exist;

2, where the file can be a file, it can be a folder;

In the Common File class we have already talked about in detail, here is not to explain

 

Two, IO streams

1, flow concept

That stream flow, flow, flow from one end to another end. The water: flow from the mountains to the others; traffic: a flow from the company to

Home; audio stream: flow from the sender to each other's ears.

File stream: flow from one end to the other end, i.e., the flow from the java memory storage medium. Storage medium comprising: a hard disk files, databases and networking node (source data). Remember: to all java memory-centric.

2, the data source

data source. Providing original raw data medium. Common: database, file, other programs, memory, network connections, IO devices.

Data sources like water tank, the fluid in the pipe flows like water flow, the program is our end-users. Flow is a draw

Like, dynamic concept, the data set is a series of continuous dynamic.

3, IO traffic classification

Thus, IO stream is very large, are classified from different angles

1), data classification

Divided by the data processing unit: byte stream and character stream. Processing data is audio, video, doc, and all text is a byte stream, can only handle text as a character stream. Usage byte stream and character stream almost identical, except that different data units are operated, a stream of bytes (8 bits), the character stream (16), the byte stream is mainly composed of a base InputStream and OutputStream class, character Reader and Writer stream mainly as a base class.

2), flow classification

The input and output streams. Java from node memory to the call input stream, called the output stream from the node memory to the java. Java input stream InputStream and Reader mainly as a base class, and the output stream OutputStream Writer mainly as a base class.

3) functional classification

节点流和处理流。从/向一个特定的I/0设备(磁盘、网络等)读写数据的流称为节点流,也常被称为低级流。 处理流则对于一个已存在的节点流进行连接或封装,常被称为高级流(装饰器设计模式)。处理流为增强、提升性能的,本身不具备直接操作节点的能力。如扩音器,就是放大声音的。 节点流处于io操作的第一线,所有操作必须通过他们进行;处理流可以对其他流 进行处理(提高效率或操作灵活性).

处理流的功能主要体现在:

a、性能的提高:主要以增加缓冲的方式来提高输入/输出的效率 ;

b、操作的便捷:提供了系列便捷的方法来一次输入/输出大批量内容

4、重点掌握

使用流抽象的概念,屏蔽了实际的 I/O设备中处理数据的细节。

 

5、操作 IO流的步骤

操作IO就跟搬家是同一个道理

核心步骤如下

1)、建立联系

2)、选择流

3)、操作:写出 读取

4)、释放资源(程序中打开的文件 IO 资源不属于内存中的资源,垃圾回收无法回收,

需要显示关闭。)

好勒,关于IO流的概念和基础知识点就先讲到这,接下来请看IO流的主要内容:输入流和输出流。乐字节原创,请多关注乐字节。

Guess you like

Origin www.cnblogs.com/lotbyte/p/11270134.html