✏️ Explanatory Question

How do the methods for writing data to a binary file differ from those used for a text file?

👁 2 Views
📘 Detailed Answer
🟢 Easy
💡

Answer with Explanation

When writing to a text file using PrintWriter, data is written as characters using methods like print() and println(). In contrast, writing to a binary file with a DataOutputStream uses methods that correspond to specific primitive data types, such as writeInt()writeDouble(), and writeBoolean(), which write the data in a machine-readable binary format.