Java IO Learning Summary

Source: Internet
Author: User

The Java IO Stream Library meets many of our basic requirements: Read and write through consoles, files, memory blocks, and even the Internet (see Chapter 15th). New input and output object types can be created (by inheriting from InputStream and OutputStream). When an object is passed to a method that was expected to receive a string, the ToString () method is automatically invoked because Java has restricted automatic type conversion. And we can redefine this ToString () to extend the kind of object that a data stream can accept.

There are still some unresolved issues in the online documentation and design process of the IO data stream library. For example, when we open a file for output, we can simply specify that once someone tries to overwrite the file, "throw" an error--some programming system allows us to specify that we want to open an output file, but only if it doesn't exist yet. In Java, however, it seems that a file object must be used to determine whether a document exists, because if it is opened as a fileoutputstream or filewriter, it will definitely be overwritten. If you specify both the file and directory paths, a flaw in the file class design is exposed because it says "do not try to do too many things in a single class"!

IO Stream Library makes us confuse some concepts easily. It does a lot of things, and it can be ported. But if there is no prior to the concept of the decorator scheme, then all the design is somewhat blind nature. So whether you learn it or teach it, it takes a little extra effort. And it's not complete: support for output formatting is not provided, this is supported by almost all other IO packages in all languages (which was not corrected in Java 1.1, which completely missed the opportunity to change the library design, adding more special situations and increasing complexity). Java 1.1 go to those IO libraries that have not yet been replaced, instead of adding new libraries. And the designers of the library don't seem to be very good at pointing out which features are disapproved and which are preferred, causing some annoying opposition in the library design.

However, once you have mastered the adorner scheme and started using the library in some more flexible environments, you will recognize the benefits of this design. By that time, the extra line of code for this should not make you feel too angry.

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.