20145317 Peng Yao "Java Program Design" 8th Week study Summary

Source: Internet
Author: User

20145317 Peng Yao "Java Program Design" 8th Week study summary textbook Study content summary 14th Chapter 1.NIO Definition

The input and output of InputStream, OutputStream, is basically in bytes for low-level processing, although the need to directly face the array, but in fact, most of the byte array in the entire block processing. The dump () method is that the whole chunk of data is read in and then the whole piece of data is written out.

Definition of 2.nio2

Nowadays, there are a variety of file systems in the world, and different file systems provide different access methods, file attributes, permission control and so on. Before the advent of JDK7, it was often necessary to write specific programs for specific files, not only in the form of no standards, but also in applications written for specific functions that would add to the burden on the application developer.
The NIO2 file System API provides a set of standard class interfaces and classes that the file system provider is responsible for as long as the application developer is working on file systems based on these standard interfaces with the class, and how the underlying file system is actually performed.

15th 15.1.1st Log API Introduction

java.util.logging Package provides a log function related classes and interfaces, the starting point for using the log is the logger class, the logger class's constructor is labeled protected, not java.util.logging the same package class cannot be created directly with new, do not use logger static Method.
Logger logger = Logger.getLogger("cc.Main")

15.1.2 specifying the log level

· LOGGER and handler, by default, filter information by level, and if you do not make any changes, the parent LOGGER configuration of the LOGGER instance is the configuration of the Logger.global-logger-name space name LOGGER instance.
• In the absence of any configuration setting, the LOGGER instance that is obtained by default must be greater than or equal to the level.info of the Logger.global-logger-name namespace LOGGER instance setting to output information.
· Handler can set the information through Setlevel (), the following information is not only to set the logger level to level.info, but also to handler the level set to Level.info.

15.1.3 using handler and formatter

• The standard API provides several action classes: Memoryhandler does not format the log information, the information is staged in the memory buffer until it exceeds the size to output the information to the specified destination handler.
· Streamhandler can specify the OutputStream to use when the information is output.
· When Consolehandler is created, OutputStream is automatically specified as System.err.
· Sockethandler can specify the host location and port when it is created.
• When establishing a Filehandler specified pattern string, you can use "%h" to represent the user's root directory, or you can use "%t" to obtain the system staging directory, or use "%g" to automatically number the document.

15.1.4 customizing Handler, formatter, and filter

handler is responsible for the output, formatter is responsible for formatting, and information filtering is by filter.
• Custom formatter, can inherit formatter after operation abstract method format (), this method will pass in LogRecord, store all log information.

15.1.5 using Logging.properties

• Changing the logger configuration can be done by Logging.properties, where the level.warning level of information output can be set.

15.2.1 using ResourceBundle

· The static Getbundle () method of ResourceBundle takes an instance of ResourceBundle, given the argument name is the main file name of the information document. Getbundle () will automatically find the corresponding. Properties document, and after getting the ResourceBundle instance, you can use the GetString () to specify the key to get.

15.2.2 using locale

• Three criteria for internationalization are regional (Locale) information, resource bundles (Resource bundles) and base names (base name)

Introduction to 15.3.1 Rule presentation

• If you have a string, you can use the split () method of string, and he returns a string array of individual substrings after the cut

15.3.2 pattern and Matcher

• When using expressions in a program, you must first parse, validate, and perform the rules representation, and make sure that the rules are syntactically correct and that the strings are compared.
The Java.util.regex.pattern instance is the representative object of the rule representation in the JVM, and the pattern's constructor is marked as private and must be obtained through the static method compile () of the pattern.
• After you have obtained an instance of pattern, you can use the split () method to cut the specified string according to a regular representation.
· Matcher () also has the ReplaceAll () method, which allows you to replace parts of a rule-compliant representation with a specified string.
Replacefirst () and Replaceend () can be substituted for the first and last part of the rule expression respectively

15.4.1 Stringjoiner, arrays new API

· The new join () static method of string allows you to specify a comma-delimited connection between each string.
· Arrays new Parallelprefix (), Parallelsetall () and Parallelsort () methods, Parallelsort () methods, you can divide the specified array into sub-arrays and sort them in parallel. Then merge the sort.

15.4.2 Steam related APIs

· Files on the lines (), list (), walk () and other methods
• Generate random numbers

Random random = new Random();DoubleStream doubleStream = random . doubles();InStream intStream = random.ints(0.100);
Learning progress Bar /Cumulative) new/cumulative)
lines of code (newBlog volume (Learning time (new/cumulative) Important growth
Goal 5000 rows 30 Articles 400 hours
Week Six 200/200 3/3 20/20
Seventh Week 400/600 5/8 15/35
Eighth Week 400/1000 8/16 20/55
Nineth Week
Resources
    • Java Learning Notes (8th Edition)
    • Java Learning Note (8th Edition) Learning Guide
    • ...

20145317 Peng Yao Java programming 8th 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.