My OS is fedora and I use the following code to create a file:
String destFile = "/var/www/html/nykkos/app/webroot/AssimilatorGenerator/Script_May6/db/"+"musics.db";
File destinationFile= new File(destFile);
if(!destinationFile.exists()) {
destinationFile.createNewFile();
}
It gives me the following exception at the line destinationFile.createNewFile()
java.io.IOException: Permission denied
Why this exception occurs and how can I overcome the same?
sudo chmod a+rwx /var/www/html/nykkos/app/webroot/AssimilatorGenerator/Script_May6/db
changes the rights for all to the directory. Better look first whether chown
, changing the owner/group might do. Or a combination of same group and giving the group all rights.
BTW createNewFile is seldom needed.
It is probably because the user you are running the JVM with has not the right permission to write at that path. But please post more deatils for a better answer.
You have to check owner
mode and permission
setting of parents directories setting. If there is no write
permission in Your OS, you will get the exception.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.