javase--Decorative Flow

Source: Internet
Author: User

Statement: The material used in this column is written by the VIP students of the Kay Academy, who has the right to be anonymous and has the final right to interpret the article; The Edith Academy is designed to promote students to learn from each other on the basis of public notes.

Decorative Flow:

Introduction: There are two kinds of flow, one is to handle the flow of transport speed, one is to deal with the flow of specific products, one read a slower, to read a batch, and this batch can not be too big, this batch is to 8k mainly on the line
If it is read up every time is 100 bytes, then the speed will be very slow, then you need to read 8k put it to the memory first cache, and then slowly provide it with, and so he is not enough when I read the 8k cache, it will be in this link to establish a caching mechanism, so that I each time the Tuen 8k here, And then give you the 8k in the cache.

Example: Using Bufferedinputstream stream to process photos
For example, the front 54 bytes is the head, each 3 bytes after the description of a pixel, the way is described by BGR, first the image into BMP format, create an input and output channel, then the head read it out, and then write the 54 bytes out, write a dead loop, each read a byte out, If you add Bufferedinputstream, it's faster.

Bufferedoutputstream
Clean up the cache is to clean up the last bit of data written in the file, directly with close words can also be done

ObjectOutputStream
Such as: can be converted to bytes by ObjectOutputStream, can be fileoutputstream output data to disk, during this time can also add a bufferedoutputstream, If you want to restore the object back, use FileInputStream.

Examples:
Want some attributes do not save to disk, you just need to add transient on the line, if the object needs to be stored on disk, you need to implement the Serializable interface, you can be tough to add a version number, change this version number it came up

And then output it to disk.

Read it up.

Java.io.IputStream

Java.io.OutputStream
ObjectOutputStream

javase--Decorative Flow

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.