JAVA IO InputStream InputStreamReader BufferedReader

Source: Internet
Author: User

InputStream, OutputStream

The abstract class that handles the byte stream, InputStream can read a byte from the source, so it is the lowest level. InputStream is a superclass of all classes of byte input streams, generally we use its subclasses, such as FileInputStream, etc.

InputStreamReader OutputStreamWriter

The abstract class that handles the character stream is a bridge of bytes flowing to the character stream, which converts the byte stream into a character stream. It reads one character at a time in a higher-level manner.

BufferedReader BufferedWriter

BufferedReader is more advanced than InputStreamReader and reads one line at a time.

InputStream is a byte-by-byte read, each time the read will execute an IO, we know that the operation of the IO is very time-consuming, which will inevitably lead to the efficiency of the program, and bufferedreader a good solution to this problem, it can read a large number of data, Greatly reduce the number of Io, efficiency is up

Three layers of progressive, so we often see this use:

FileInputStream fis=New FileInputStream ("D://desktop//test.txt");

InputStreamReader isr=New InputStreamReader (FIS,"UTF8");

BufferedReader br=New BufferedReader (ISR);

Get input to the keyboard:

BufferedReader bufr = new BufferedReader (new InputStreamReader (system.in));

Similar to scanner, but more powerful than scanner, because scanner cannot get input with a space, enter key

JAVA IO InputStream InputStreamReader BufferedReader

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.