Analysis of Java's stream

zhaozj2021-02-08  239

Since there is a Java input and output operation, I have a few days, I have a few days, and I have a little understanding of Java's stream technology, but there are still many not very clear. Below is some of my books, some notes, strict Say it should not be original, I posted it just hope to have some help to everyone.

1. Java has a complete stream type, the total number exceeds 60, and the four abstractions constitute the foundation of these classes.

INPUTSTREAM and OUTPUTSTREAM read and write byte-based byte data streams;

Reader and Writer read and write byte data streams based on double bytes of Unicode characters;

2, reading and writing of binary data

DataInputStream and DataOutputstream

You can complete read and write to all basic Java types;

FileInputStream and FileOutputStream

The data stream involved in a disk file is input and output is a read and write operation of the byte stage;

3, Java's stream type is divided into two categories:

(1) Read bytes data (such as FileInputStream) from a file or some special places;

(2) Put these byte data "assemble" into a more useful data type (such as DataInputStream, PrintWriter)

To complete the specific operation, you need to assemble the flow.

4, Java's flow does not have pre-read and buffer, need additional processing

BufferInputStram conveys a buffer process;

PushbackInputStream performs pre-reading process;

5, randomaccessfile randomly access file, this class also implements DataInput and DataPut;

6, text stream, the tools of the human eye can be identified by the tools of the host environment

Since Windows string writes are ASCII format, write Unicode encoding into a text file, use the host environment, the human eye cannot identify the file content, Java provides a stream filter to make up Unicode encoding and native operating system Character encoded cracks.

7. InputStreamReader special coding scheme Enter the word stream converted to Unicode characters; this class uses the host's default code, using ISO 8859-1 encoding in Windows, "asni" encoded;

OutputStreamWriter converts Unicode character stream to a special coding scheme word throttle

8, FileReader and FileWriter

Ready and write the disk file, which has been made up for the Unicode encoding and the coded cracks, which can be used directly.

9, write text output:

Binary write data: DataOutputStream;

Text format write data: PrintWriter;

Read text input:

Binary read data: DataInputStream;

Text format read data: BufferReader;

10, other streams

Such as: ZipinputStream and zipoutputstream

Read and write the ZIP file

Welcome to my homepage http://flying965.myrice.com

转载请注明原文地址:https://www.9cbs.com/read-1974.html

New Post(0)