Java IO (12) CharArrayReader and Chararraywriter

Source: Internet
Author: User

Reprint please indicate source: http://www.cnblogs.com/lighten/p/7082668.html

1. Preface

This chapter introduces the character array flow, the function and the Bytearrayinputstream byte array flow is the same, so the introduction is relatively simple, the front has seen, you can skip directly, no difficulty.

2.CharArrayReader

It has a cached character array, the current read position, the marker bit and the total data length, and accepts a character array as the input source. That's the cache. The read is then read to the accepted data.

The Read method, if the current position is greater than or equal to the total data length, means that the read is finished, returns 1, otherwise returns the position of buf[], position +1;

Read the array and simply judge the copy.

Skip is the POS shift. The premise is that there are so many bits that can be moved. Other methods are not introduced.

3.CharArrayWriter

This class is even simpler, which is to write the characters to the built-in buf, counting the count. The default buf size is 32.

Write, not enough to increase by one times. Copy.

This method is to write the existing data to a writer, note that no buf is not reset.

Returns the data currently written. The other close and flush methods are empty methods. The rest is nothing to say.

Java IO (12) CharArrayReader and Chararraywriter

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.