20145331 Java Programming 6th Week of study summary

Source: Internet
Author: User

20145331 "Java Program Design" 6th Week Study Summary Textbook Study summary Tenth chapter input/output 10.1.1 stream

java the input/output to a stream, the source and destination of the data, and the stream object that connects the two.

• To remove data from the source, you can use the input stream, or you can use the output stream if you want to write data to the destination. The input stream represents the object as an Java.in.InputStream instance, and the output stream represents the object as an Java.io.Outputstream instance

• Each time the data is read from InputStream, the byte data is placed first, and its read () method attempts to read the Btye data and returns the bytes read in.

• When you do not use InputStream and outputstream, you must use the close () method to close the stream. Because InputStream and Outputstrem operate the Java.io.Closeable interface, whose parent interface is the Java.lang.AutoCloseable interface, you can use JDK7 to try to automatically turn off resource syntax.

10.1.2 Streaming Inheritance Schema

System's Setin method specifies the standard input source, setout specifies the output destination, the standard output can be directed to the document, as long as the program is executed using > directs the output to the specified document.

FileInputStream is a subclass of InputStream, the main operation of InputStream's read () abstract method, FileOutputStream is a subclass of OutputStream, the main operation of its write () method.

10.1.3 Stream Processing Adorner

• Adorners only perform some processing of the data, such as buffering, serialization, data loading, etc.

Bufferedinputstream and Bufferedoutputstream provide buffer functionality primarily internally.

10.2 Character Processing class

Reader abstract class: An abstract class used to read a stream of characters. Subclasses must implement only read (char[], int, int) and close (). However, most subclasses will override some of the methods defined here to provide higher efficiency or other functionality.

writer Abstract class: An abstract class that writes a stream of characters. Subclasses must implement methods that have only write (char[], int, int), flush (), and Close (). However, most subclasses will override some of the methods defined here to provide higher efficiency or other functionality.

FileReader, FileWriter can read or write to the document.

11th thread vs. parallel API11.1 thread

• Single-threaded programs: The program starts from the main () program entry point from the beginning to the end of only one process.

• Multi-threaded programs: A program has multiple processes.

• How to compose multithreaded procedures: operate the Runnable interface, define additional processes in run (), inherit the thread class, and define additional processes in run ()

• The advantage of operating the Runnable interface is that it is more resilient and the class has the opportunity to inherit other classes; If you inherit the thread class, that class is a thread, usually in order to directly take advantage of some of the methods defined in thread to inherit the thread.

• Basic state diagram:start-->runnable--> (blocked)-->running-->dead

• If you want to stop a thread, it's best to do it yourself, and let the program go through the due process instead of calling the Syop () method

• A race condition may be triggered when a thread accesses the same object's same resource (Race Condition)

Wait (), notify (), Notifyall () are methods defined by the object, which can be used to control whether the thread releases the lock on the object or to notify the thread to participate in the lock contention.

11.2 Parallel APIs

• When using the Advanced parallel API, the Operation object of the lock interface implements synchronized functionality.

• When using the Advanced parallel API, the condition interface's operand can implement the Wait (), notify (), Notifyall () functions of object.

Problems in code debugging and the resolution process

Common methods in the InputStream class:

    public abstract int read( )    public int read(byte b[ ])    public int read(byte b[ ], int off, int len)    public int available( )    public long skip(long n)    

Common methods in the OutputStream class:

    public void write(byte b[ ])       public void write(byte b[ ], int off, int len)    public abstract void write(int b)     public void flush( )      
This week code hosting other (sentiment, thinking, etc., optional)

More and more knowledge, more and more difficult, feel the front of the content I forgot a lot, the future in the process of learning, should pay attention to review the contents of the front, so that the temperature to know the new.

At the beginning of learning the focus of the study on the grammar and skills, not too much attention to the API learning, which let me in this two weeks of learning to eat the pain, API is an important part of Java, in the future learning can not have the luck psychology, to learn every knowledge point, will have a qualitative improvement.

Learning progress Bar

Lines of code (new/cumulative) Blog volume (Add/accumulate) Learning time (new/cumulative) Important growth
Goal 3500 rows 20 articles 300 hours
First week 150/150 1/1 14/14
Second week 150/300 1/2 14/28
Third week 100/400 1/3 14/42
Week Four 200/600 1/4 14/56
Week Five 317/917 1/5 14/70
Week Six 355/1272 2/7 16/86
Resources
    • Java Learning Notes (8th Edition)
    • Java Learning Note (8th Edition) Learning Guide

20145331 Java Programming 6th Week of study summary

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.