我已经设置了文件权限,但我仍然无法将图像从一个文件夹移动到另一个文件夹

i have set file permissions still i cannot move images from one folder to another

我写了一个 java 代码来将图像从一个文件夹传输到 java 中的另一个文件夹。我设置了文件权限,如:

file.setReadable(true, false);    
file.setExecutable(true, false);    
file.setWritable(true, false);  

但是 setWritable 正在返回 false。请帮助我。

如果 setWritable(true, false) 返回 false 如果操作失败。

正如 javadoc 所说:

The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.

找出为什么你的应用程序没有权限,然后你可以找出你需要做什么来解决这个问题......或者你不能修复它。

(运行 作为 "the administrator" 的代码可能有效也可能无效。例如,如果您的应用程序是 运行 在 SELinux 处于强制模式的系统上的服务,那么即使 "root" 权限也不会让您覆盖 SELinux 策略文件设置的规则。)