Home / Questions / What is the purpose of "chaining" or combining stream objects, such as linking a BufferedWriter to a FileWriter?
Explanatory Question

What is the purpose of "chaining" or combining stream objects, such as linking a BufferedWriter to a FileWriter?

👁 1 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

Chaining stream objects allows for combining the functionality of different stream classes, a process known as filtering. For example, a FileWriter object creates an output stream to a file, and linking a BufferedWriter to it adds buffering capability. Further linking a PrintWriter provides convenient print and println methods for writing formatted text to the buffered stream.