JDK source code analysis-the wrapper class in the IO stream uses the decorator pattern

JDK source code analysis

The wrapper class in the IO stream uses the decorator pattern.

BufferedInputStream,

BufferedOutputStream,

BufferedReader,

BufferedWriter



Let's take BufferedWriter as an example to illustrate, first look at how to use BufferedWriter

It really feels like decorator mode to use, let's look at their structure:

summary:

BufferedWriter uses the decorator pattern to enhance the Writer sub-implementation class, adds a buffer, and improves the efficiency of writing data.

Guess you like

Origin blog.csdn.net/qq_39368007/article/details/113998454