The problem is at these lines:
The first line will create a new directory called "My New Folder".
The second line will try to create a file called "My New Folder". When you look at the API, you will notice that instantiating a new FileWriter using the constructor that takes a
String will try to create a file with that String value as a name. But since you've already created a directory with that name, there's where it fails.
So the second line should be:
And your good to go.
P.s. I'm not getting why your trying to create a FileWriter that refers to a directory anyway?