A preliminary study of I/O flow in Java (i)

Source: Internet
Author: User
A. Flow

Flow, here is the image of the data exchange method. The process runs in memory and avoids data interactions with the outside world during the run. For example, the data from the hard disk, console, pipe and even sockets (the specific point should be the network card on our computer) read into the address space occupied by our process lock. This data exchange process, which we call a stream. The operation on the stream is called the I/O operation.

Two. Decorator mode

Before we introduce I/O operations in Java, let's introduce decorator mode.

Decorator mode is the combination of objects. If we add a new method to a class, and we don't want to modify the class (or the class might have been compiled and cannot be modified), you can use the inheritance method. At a later time, there are new features that can be used again in an inherited manner. This is simple, but over time will cause the number of our subclasses to swell rapidly. This embarrassment can be solved if we use decorator mode.

Decorator Mode illustration

Car is a very simple function can only run, but we let it fly in the sky, swimming in the water, autonomous driving, and even may appear in the future more functions, we can use the decorator mode.

    • ICar an abstract component role, which can be an interface or a specific class
    • Car Specific Component role
    • Supercar decorator, with references to abstract artifacts
    • Flycar,watercar,aicar specific decorative roles, adding new features to specific artifacts

  

Create a car that can fly and swim new water (new Flycar new car)

Third, the decorator mode in I/O

Some classes are not represented in the diagram.

Input is an abstract component, and FilterInputStream is a decorator

  

A preliminary study of I/O flow in Java (i)

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.