Skip to content
Advertisement

Unable to create FileWriter

I am trying to create a FileWriter instance pointing to a folder were everyone has write access:

JavaScript

And I am getting java.io.FileNotFoundException with detail message:

JavaScript

The folder exists and if I stop in debugger and evaluate expression below it always returns true as it should:

JavaScript

I don’t understand what is going on. I am using intelij and I have Windows 7 operating system and I am trying to run this using Java 8.

Thank you in advance.

Advertisement

Answer

You have reported expected behaviour . On Windows any attempt to write to a directory with FileWriter will fail, giving access denied:

JavaScript

Changing the path to a file within the folder should work fine as long as the filename provided is writable:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement