Due to the security policy you can't write to the directory you are using.
Only the deployment/data/tmp directory is available for writing files.
To write to another directory turn off the emulate could security in your project settings, but be aware that this will not function in a cloud environment.
Because you are not allowed to write to any path. In this post you can find the java code to find the path where you are able to write to.
Regards,
Ronald
[EDIT]
This path also works in the Mendix cloud so you do not have to change the security policy.