0

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?

Community
  • 1
  • 1
Haseena
  • 484
  • 2
  • 11
  • 25
  • 3
    See the answer [here](http://stackoverflow.com/questions/664432/how-do-i-programmatically-change-file-permissions) – didster Oct 08 '12 at 09:00

1 Answers1

2

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) {}
Tarun Gupta
  • 1,232
  • 2
  • 13
  • 26
PbxMan
  • 7,525
  • 1
  • 36
  • 40
  • Try based on the above code, after executing this, Iam trying to create mysql table, it shows error like this : ERROR 1 (HY000): Can't create/write to file '/home/test/Sample/test1/sample.MYD' (Errcode: 13) (The specified directory now gain full permission. But table couldnot be created) – Haseena Oct 08 '12 at 09:56
  • check the owner and group permission for that newwly created dir. – Gnanz Oct 08 '12 at 10:58