Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

There are several design patterns utilized in java.io, but the most commonly used patterns are:

  1. Decorator pattern: This pattern is used in Java I/O streams to add new functionality to existing streams without modifying their source code.

  2. Factory pattern: Java I/O classes use the Factory pattern to create objects of different types depending on user requirements.

  3. Observer pattern: Used in Java's InputStream and OutputStream classes to notify when read and write operations are performed.

  4. 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.

  5. Template Method pattern: Used in the java.io class hierarchy to define the structure of an algorithm and allow subclasses to implement specific steps.