I had this java application where the system created a file. Since the file was created in a part of the directory structure that was locked down tight, I needed to alter the permissions of the file from the java class before I could operate on it. I made a chmod java class with a static method to do it. This is how I did it:
package com.newco.utils;
import com.sun.jna.Native;
// used to grant privileges to system created files.
/**
* The Class Chmod.
*/
public class Chmod {
/** The libc. */
private static CLibrary libc = (CLibrary) Native.loadLibrary("c",
CLibrary.class);
/**
* Chmod.
*
* @param pathe
* the pathe
* @param val
* the val
*/
public static void chmod(String pathe, int val) {
libc.chmod(pathe, val);
}
}
No comments:
Post a Comment