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