✏️ Explanatory Question

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

👁 1 Views
📘 Detailed Answer
🟢 Easy
1
Total Views
10
Related Qs
0%
Progress
💡

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.