Java-based I/O stream (3)-------Conversion stream

一. The concept of conversion stream:

Transform stream is a package stream, which can convert byte stream into character stream. It is also possible to convert a character stream into a byte stream.

        二.Byte stream character stream:

1.InputStreamReader is a bridge of byte circulation to character stream: it reads bytes using the specified charset 解码 is a character. The character set it uses can be specified by name or explicitly given, or it can accept the platform's default character set.

                    2. Use:

Step: Byte stream data: InputStream is =;

Step 2: Convert byte stream to character stream: InputStreamReader isr = new InputStreamReamder( Is);

Step 3: Efficient decoration of character stream: BufferedReader in= new BufferedReader(isr);

Of course, for efficient use, it can be directly packaged as:

                        BufferedReader in= new BufferedReader(new InputStreamReader(;

三. Character stream byte stream:

                       1.OutputStreamWriter is a bridge of character circulation to byte stream:Use the specified charset character to be written to the stream 编码|| | into bytes. 成字节。

                       2.Use to convert byte stream to character stream almost

For efficient use, you can directly package it as:

                           Writer out = new BufferedWriter(new OutputStreamWriter(System.out));

四. Summary:

                       1.| || Currently learned stream: 目前已经学过的流:


                       2.General rules for using streams:



                       3. Stream related exercises:


1). method_1() reference answer :


2). method_2()Reference answer:



3). method_3()Reference answer:



3). method_4()Reference answer: