Summary of the study contents of the textbook 14th chapter-nio and Nio2nio and IO differencesNio
- Channel Inheritance Framework
-
To get the channel operand, you can use the channels class, which defines the static method Newchannel (), which allows you to create Readablebytechannel from InputStream, OutputStream, respectively, Writablebytechannel, some inputstream, OutputStream instances themselves also have methods to obtain channel instances, such as: Fileinputsteam, FileOutputStream has a Getchannel () method to obtain FileChannel instances respectively.
- Buffer Inheritance Schema
- The direct subclasses of buffer have a allocate () static method that allows you to specify the buffer capacity (capacity), and if you want to get an array inside buffer, you can use the array () method, and if there are any arrays that you want to convert to a buffer subclass instance, Each buffer subclass instance has a wrap () static method to provide the operation.
-
Buffer is a container, the filled data will not exceed its capacity, the capacity size can be obtained using the capacity () method, the actual readable or written data limit (limit) index value can be learned or set by the limit () method, The location (Position) index value of the next readable data, which can be learned or set using the Position () method.
NIO2 File System
- The NIO2 file System API provides a standard set of interfaces and classes that the application developer is responsible for as long as the file system operates on these standard interfaces and classes, and how the underlying file system is actually performed.
15th-Generic API Generic API
- LOG: Log information security is significant, audit, forensics, intrusion detection, etc. will use the log message
- Log API
- Logger: Note You cannot use construction methods to generate Logger objects. 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("xxx");
- GetLogger: When calling GetLogger (), you must specify the namespace to which the logger instance belongs, with the namespace "." As a hierarchical distinction, the logger of the same namespace level, whose parent logger is configured identically. The namespace is named as the class full name, usually in which class the logger is obtained.
- Specify the log level
- Getlevel:
- The parent logger configuration of the logger instance obtained is the logger instance of the namespace, which can be obtained by acquiring the set instance of the level
Logger.GLOBAL_LOGGER_NAME getParent() logger getLevel() .
-
SetLevel: You can setLevel() set the level instance, if log () specifies that the lever instance contains an int value that is less than the int value in the level instance set by logger, level does not log information
- Handler: Output Media
- Memoryhandler: The log information is not formatted and the information is staged in the memory buffer until the buffer size is exceeded to output the information to the specified destination handler.
- Streamhandler: You can specify the OutputStream instance that is used when the information is output, and it will use the specified formatter formatting information with subclasses.
- Consolehandler: When created, OutputStream is automatically specified as System.err, so the log information is displayed in the console.
- Filehandler: The fileoutputstream that is used when creating the log output when it is created, and the document location and name can be specified using pattern string strings.
- Sockethandler: The host location and port can be specified at creation time, and the internal network will be automatically established to transfer log information to the specified host.
- Formatter: Formatting
- Filehandler The default formatter is
XMLFormatter ;
- Consolehandler is used by default
SimpleFormatter , these two classes are subclasses of formatter and can be setFormatter() set formatter by handler method.
-
Filter: Filtering
Internationalization Basics
- Localization localization; internationalization (i18n) internationalization
- 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 () The corresponding. Properties document is automatically found and can be obtained using the GetString () specified key after the ResourceBundle instance has been obtained.
- Locale
- 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.
Regular Expression
- Introduction to Regular expressions
- Characters and metacharacters: letters and numbers are compared by literal means in regular expressions, and some characters are preceded by \ and are treated as meta-characters.
- Character class: In a rule expression, multiple characters can be grouped together and become a character class. One way to categorize characters is to descriptors the word in [].
- Pattern/matcher
- In the program to use the expression, you must first for the rule representation of the analysis, validation, and so on, to determine the rules of expression syntax error, the string is 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 by a regular representation, which is equal to the split () method using String.
JDK8 API Enhancements
- JDK8, String adds a join () static method that can be used directly
String message = String.join("-","Java","is","cool");will produce "Java-is-cool"
- In JDK8, a number of methods have been added to arrays for parallelism of large arrays.
parallelPrefix()方法You can specify a Xxxbinaryoperator instance to perform a stream-like reduce () method.
parallelSetAll()方法Used to initialize an array or to completely reset each index element.
parallelSort()方法You can divide the specified array into sub-arrays and sort them separately at the time of parallelism.
Problems in teaching materials learning and the solving process
- Question 1: How to correctly represent greedy regular expressions
-
Problem 1 Solution: greedy, non-greedy, exclusive quantifier: {n} is a kind of greedy quantifier notation, indicating that the preceding item appears n times. After the greedy quantifier notation is added? , it will become a step-by quantifier (lazy quantifier, non-greedy quantifier)
- Question 2: When using Resourcebunde, how do I get the corresponding information document based on the underlying name?
- Problem 2 Solution: (1) Use the specified local object to obtain the information document, (2) Obtain the information document using the object obtained by Local.getdefault (), and (3) Obtain the information document using the base name.
Code hosting last week error analysis of exam
Self-rated: 8
- Problem and solution process in textbook learning, one question plus 1 points
- Valid code for this week exceeds 300 branches (plus 2 points)
- -Beautifully formatted plus one point
- -Add 1 points to the progress bar to record the learning time and improvement situation
- -Learn to add 1 points to the wrong question
20145234 Huangfei The eighth week of Java programming