Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 如何以编程方式更改文件权限? 如何在 java 中设置 umask?
在Linux中,我试图为文件夹结构(例如:“home/test/sample/”)授予完全权限(777),以创建MySQL表,并将数据目录从我的应用程序更改为用户特定位置用Java编写。
如何从Java授予对文件夹结构的完全权限?
您必须像这样使用依赖于操作系统的代码:
Runtime rt = Runtime.getRuntime(); Process proc; int exitVal = -1; try { proc = rt.exec("chmod 777 "+file); exitVal = proc.waitFor(); } catch (Exception e) {}