Unless you deploy on premises, you have almost no permissions to write data on the Mendix server. The only place where you can write files to is a temporary folder. To access the path, you need to use Core.getConfiguration.getTempPath(), as in the example code below.
public static File getTempFile (String fileName) {
String fileSeparator = Core.getConfiguration().getFileSeparator();
File tempPath = Core.getConfiguration().getTempPath();
File file = new File(tempPath + fileSeparator + fileName);
return file;
}