Developer/Designer Notes

Java File Permissions

Posted by Kiran Mova on March 19, 2007

How to set the permissions of a file at runtime using Java? My requirement is very simple. I want to create a file with ‘777’ on linux.

With Java 1.6, I can use the method setWriteable(), setExecutable().

But prior to Java 1.6, there is no programmatic way to achieve this. The awkward work-around is to use the “Runtime.exec()” method and invoke ‘chmod 777’ on my file. The other workaround is to use JNI (I would never try that..) to invoke chmod. Check this thread at Java Forum.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: