✏️ Explanatory Question

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

👁 16 Views
📘 Detailed Answer
🟢 Easy
💡

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.