When writing to a file in Java what happens if you choose a

When writing to a file in Java, what happens if you choose a file that already exists? What if you choose a file that does not exist?

Also, where in a method should you declare that it throws an exception?

Solution

If file already exist then it create a new file deleting older content.

If file does not exit, it creates a new file

So, in either case it create a new file.

At place where you create a FIle Object and you read/write to file, it should declare throws an exception

When writing to a file in Java, what happens if you choose a file that already exists? What if you choose a file that does not exist? Also, where in a method sh

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site