✏️ Explanatory Question

When writing to a file, what is the default behavior if the specified file already exists, and how can this behavior be changed?

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

Answer with Explanation

By default, if a file does not exist, it will be created. If it already exists, the output stream overwrites the existing contents of the file. To change this behavior and append new data to the end of the file, you must provide an additional boolean true argument when creating the FileOutputStream or FileWriter object.