简体   繁体   中英

Java Application can't write to disk though full permissions are given

I am trying to write to C:\\{foldername}\\batches\\{date}\\batch.csv from a Java application. Admin accounts are able to write to the folder, but those without an admin account cannot. The non-admin users have full permissions to write to that folder, creating directories and files as well as updating, and they can do so using Explorer but not the application. I also have a SQL file that outputs to a similar directory that works just fine under a standard user ever since those users got write permission to that folder. I assume it is a permissions issue, but they have full permission on the folder. Insight?

You can check if the File is writable using the following-

File f = new File("path");
if(f.canWrite()) {
  // write access
} else {
  // no write access
}

Try to exclusively make the file writable using the following if it is a permission issue-

file.setWritable(false);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM