Dark Horse programmer-io (2)

Source: Internet
Author: User

--------------------- Android training, Java training, and hope to communicate with you! ---------------------- I/O (ii) rules for use of various streams 1. Io streams have four systems-byte input streams, byte output streams, Character Input streams, and character output streams. 2. When the operated data is plain text data, try to use the byte stream form. to operate other types of data, use byte streams. In fact, the bytes stream only encapsulates the byte stream, so that it is added to the encoding table and easier to operate. 3. Identify the Source Device for the operation, such as memory, hard disk (file), and keyboard. The data in the memory can be used directly. The files on the hard disk use fileinputstream (the data is not plain text) and filereader (the data is plain text). The input on the keyboard uses the standard input stream system. in (the inputstream type is returned ). 4. Identify the target device: memory, hard disk (file), and console. Similar to the above, the data in the memory is used directly. The files on the hard disk use fileoutputstream (the data is not plain text) and filewriter (the data is plain text). The output in the console uses the standard output stream system. out returned ouputstream. 5. Stream modification. In order to make the stream more efficient, bufferedinputstream, bufferedoutputstream, bufferedreader, and bufferedwriter are generally used as decoration classes with cache. Corresponding to the original node stream. 6. The conversion between two byte streams. Using outputstreamwriter and inputstreamwriter, you can modify the byte stream in the upstreaming stream and use the upstreaming stream to perform operations. This makes text operations easier and more convenient. This conversion can also be embedded into the character encoding table to store or read the data in a certain encoding format. This stream is used when you need to change the storage encoding format. In fact, the delimiter stream (filereader and filewriter) is a default Stream object that transfers byte streams to the delimiter stream. 7. If you want to merge multiple files into one file, it is very convenient to use sequenceinputstream. It can put multiple stream objects together (more than three objects are put together by enumeration ). 8. If you want to split a file into multiple files, you can directly create the output of the file multiple times in the loop. 9. Store the object information in the file and read the object from the file. Use objectinputstream and objectoutputstream. The premise is that this object implements the serializable interface. 10. There are two types of print streams: printstream and printwriter. They directly use the println method to print with line breaks. 11. If you need to obtain the row number when reading the document, it is very convenient to use linenumberreader. Of course, linenumberinputstream can also be used. -------------------- Android training, Java training, and hope to communicate with you! ---------------------- For details, please refer to: http://edu.csdn.net/heima

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.