Differences between java. io. Reader and java. io. InputStream

Source: Internet
Author: User

Java. io. Reader and java. io. InputStream constitute Java input classes. Reader is used to read 16 characters, that is, Unicode-encoded characters. InputStream is used to read

Input ASCII characters and binary data.
In Java, different types of Reader input streams correspond to different data sources:

FileReader is used for input from a file;

CharArrayReader is used to input character arrays from the program;

StringReader is used to input strings from the program;

PipedReader is used to read data written to the pipeline from PipedWriter in another thread.

Different types of InputStream input streams correspond to different data sources: FileInputStream, ByteArrayInputStream, StringBufferInputStream,

PipedInputStream. In addition, there are two InputStream input streams that do not have the corresponding Reader type:

Socket is used for sockets;

URLConnection is used for URL connection.

These two classes use getInputStream () to read data.

Correspondingly, there are similar differences between java. io. Writer and java. io. OutputStream.



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.