Use of conversion streams (Inputstreamreader,outputstreamwriter)

Source: Internet
Author: User

How do we set the encoding and decoding format of byte input stream, byte output stream?

In the byte input stream (inputstream), byte output stream (OutputStream), there is no method for setting the encoding and decoding format. the API documentation for InputStream is as follows:

Since the byte input and output stream does not provide the appropriate method, let us set the encoding and decoding format.

Then we will use the conversion stream to set the encoding of the byte stream.

What is a conversion stream? through the API, it is known that the transition stream is a bridge of bytes flowing to the character stream. It reads the bytes using the specified charset and decodes them to characters. The character set it uses can be specified or explicitly given by name, or it can accept the default character set of the platform. For example: InputStreamReader API:This is good to do, we just put the input stream "into" the conversion stream, and then assign it a character set, it will encode itself . such as: New InputStreamReader (New InputStream (), "UTF-8");New OutputStreamWriter (New OutputStream (), "UTF-8");
 from for Notes (Wiz)List of attachments
    • 360 Feedback 165801057571126.png
    • 48de37d2-294d-46d0-a3cc-211c0e0737c2.png

Use of conversion streams (Inputstreamreader,outputstreamwriter)

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.