20145239 Java Programming 8th Week learning Summary Textbook Learning content summary General API
Log API
1. 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, will be allowed to use logger static party Law, such as: Logger logger = Logger.getLogger("cc.openhome.Main")
.
2. The way to obtain logger: Logger logger = Logger.getLogger("Main.class.getName")
.
3. The same namespace-level logger, the parent logger configuration will be the same, each logger after processing their own log action, will propagate to the parent logger, so that the parent logger can also process the log.
1. In the absence of any configuration settings, the default LOGGER instance, the level must be greater than or equal to the Logger.global-logger-name namespace LOGGER instance set Level.info, can output information.
2.Handler can be set by Setlevel () information, the following information is not only to set the level of logger to level.info, but also to handler level set to Level.info.
- Using handler and Formatter
- 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.
- 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.
- Customizing handler, formatter, and filter
Custom formatter, which can inherit formatter after the operation of the abstract method format (), this method will pass in LogRecord, storing all the log information.
The logger configuration can be changed by logging.properties.
Internationalization Basics
In the case of non-modification of the application, according to different users directly using different languages, date format, such design considerations called internationalization, referred to as i18n.
- For text messages that may change in the future, consider moving the information outside of the program and using ResourceBundle for information binding.
.properties
The document must be placed under the path setting of the classpath, the key/value pair is written in the document, and then the key can be used in the program to get the pairing.
- 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.
- The three criteria for internationalization are region (Locale) information, resource bundle (Resource bundle) and base name.
- The area information represents a specific geographic, political, or cultural area, which is specified by a language code (represented by two lowercase letters) and an optional region code (denoted by two uppercase letters). The corresponding class of region information is locale, such as
Locale locale=new Locale("zh","TW");
.
- The resource bundle includes information about a specific region.
- Each resource bundle that represents the same set of information but different regions share the same base name.
Rules table
Introduction
- The rule expression is used primarily for character, string format comparisons, including literal meaning characters and meta characters. literal meaning characters are characters that are compared by literal meaning, and metacharacters are non-literal comparisons that have different meanings in different contexts.
- If you have a string, you can use the split () method of string, which returns a string array that consists of the individual substrings after the cut.
Pattern and Matcher
- 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 in accordance with a regular representation.
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.
This week's code hosting
Other (sentiment, thinking, etc., optional)
I used to be lazy, do not want to see the learning sister git tutorial, has been using the method of Web copy managed code. Today calm down to follow the steps to set up a step-by-step git, in the constant encounter problems and ask the students finally the first time
This week's code is hosted using a GIT client. This feeling of joy is I did not think of, in fact, many things are not so difficult to imagine, as long as willing to drill, Ken next time, there will be some harvest!
Learning progress Bar
|
lines of code (new | /Cumulative)
Blog volume ( | new/cumulative)
Learning time (new/cumulative) |
Important growth |
Goal |
5000 rows |
30 Articles |
400 hours |
|
First week |
150/150 |
1/2 |
15/15 |
|
Second week |
350/500 |
1/3 |
20/35 |
|
Third week |
400/900 |
1/4 |
35/70 |
|
Week Four |
490/1890 |
1/5 |
40/110 |
|
Week Five |
592/2882 |
1/6 |
30/140 |
|
Week Six |
686/4368 |
2/8 |
30/170 |
|
Seventh Week |
708/4776 |
2/10 |
15/185 |
|
Eighth Week |
846/4822 |
2/12 |
15/200 |
|
Resources
- Java Learning Notes (8th Edition)
- Java Learning Note (8th Edition) Learning Guide
20145239 Du Wenshu Java Programming 8th Week of study summary