How to set 777 permission on a folder structure in Linux from Java? [duplicate]
-
05-07-2021 - |
Pergunta
Possible Duplicate:
How do i programmatically change file permissions?
How can I set the umask from within java?
In Linux, I am trying to give full permission (777) to a folder structure (say ex: "home/test/sample/") for creating a MySQL table with changing the data directory to the user specific location from my application which is written in Java.
How can I give full permission to a folder structure from Java?
Solução
You have to use a Operating System dependent code just like this:
Runtime rt = Runtime.getRuntime();
Process proc;
int exitVal = -1;
try {
proc = rt.exec("chmod 777 "+file);
exitVal = proc.waitFor();
} catch (Exception e) {}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow