Permission to modify a file is 777 for example:
/** executes the Linux command and returns execution results.
* * public static String exec (string[] args) {string result = ' ";
Processbuilder Processbuilder = new Processbuilder (args);
Process process = NULL;
InputStream erris = null;
InputStream Inis = null;
try {bytearrayoutputstream BAOs = new Bytearrayoutputstream ();
int read =-1;
Process = Processbuilder.start ();
Erris = Process.geterrorstream ();
while (read = Erris.read ())!=-1) {baos.write (read);
} baos.write (' n ');
Inis = Process.getinputstream ();
while (read = Inis.read ())!=-1) {baos.write (read);
} byte[] data = Baos.tobytearray ();
result = new String (data); catch (IOException e) {E.printstacKtrace ();
catch (Exception e) {e.printstacktrace ();
Finally {try {if (Erris!= null) {erris.close ();
} if (Inis!= null) {inis.close ();
} catch (IOException e) {e.printstacktrace ();
} if (process!= null) {Process.destroy ();
} return result; }
Here we call the above function where we need to:
string[] args = {"chmod", "777", "(File Path)"};
exec (args);