javase--data type stream, memory stream, print stream

Source: Internet
Author: User

Class Number: VIP17 student Name: Xiao Wu Course name: javase

Data type Flow

DataOutputStream is the data type output stream, which can write the basic data type directly into the file;
DataInputStream is a data type input transmission, it can be the basic data type directly read to the program, the first to write out what order, read in the order to read in accordance with the sequence of reading, sequential reading counter will be garbled or incorrect data, all the flow is in accordance with the first-out principle. Write to the file first:

and read it in the file:

Memory stream

In memory, an array is an area where data is stored, so arrays are also called data buffers, so byte arrays are buffers.
Bytearrayinputstream is a byte array input stream, which is given a byte array when the new object is a buffer within the input stream of the byte array. We used to read the data on a disk file, and now we read the data from memory, the data source is the buffer inside the byte input stream, so the byte input stream is the function of converting the byte array into the input stream, that is, bytearrayinputstream a byte array as the source of the stream input:

Bytearrayoutputstream is a byte array output stream, it also has a buffer inside, the new object is not allocated, the default is 32 bytes, its function is to convert the flow into a byte array, is to write bytes into the buffer, and the byte input stream, the opposite, That is, Bytearrayoutputstream can use a byte array as the output destination of a stream. Byte output stream There are two ways to take the data out of the buffer: toString () and Tobytearray ().

Memory Flow structure diagram:

Memory flow exists meaning: Byte output stream can intercept memory data, when a method needs an output stream, the byte output stream to this method, the method inside the operation of the data will be written to the byte output stream, when the close () method is called, the data in the buffer will not disappear, unless the program is closed, Then we can take out the data in the buffer.

Print Flow

PrintStream print stream, which can print information to anywhere, disk files and consoles, it can print general information, or can print exception information. When the new object is given an output stream, it prints the information to the point where the output stream is pointing. It can print any data information. The system class has two methods to set the output stream SetOut () and Seterr (), which can be sent to the print in:

javase--data type stream, memory stream, print stream

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.