1 | initial version |
There are several design patterns utilized in java.io, but the most commonly used patterns are:
Decorator pattern: This pattern is used in Java I/O streams to add new functionality to existing streams without modifying their source code.
Factory pattern: Java I/O classes use the Factory pattern to create objects of different types depending on user requirements.
Observer pattern: Used in Java's InputStream and OutputStream classes to notify when read and write operations are performed.
Adapter pattern: Used for conversion between different data formats in Java I/O classes, e.g., the InputStreamReader and OutputStreamWriter classes convert bytes to characters and vice versa.
Template Method pattern: Used in the java.io class hierarchy to define the structure of an algorithm and allow subclasses to implement specific steps.