setting permissions to a file !!
1 posts in topic
Flat View  Flat View

Posted By:   Naredla_Amarendar
Posted On:   Saturday, April 14, 2001 05:56 AM

hi, i created a file using new File() feature, i wrote some content into it.
i tried to set execute permission on this file using FilePermission class.
it is giving that above permission is set when i printed it using getActions() meththod. but in reality (i.e., in directory explorer) it is not effected.
can any one pls help on this, how to set filepermissions to a file using java code.
i am working on linux redhat.

Re: setting permissions to a file !!

Posted By:   Nathan_Meyers  
Posted On:   Monday, April 16, 2001 09:28 PM

FilePermission is used in a very different way than
you are trying to use it. It is used to describe permissions
requested and granted to Java code - for example, whether
code can execute a file or write to a directory.

The thing you are trying to do - change file modes -
is not supported from Java because it is not portable
across Java platforms. You could solve the problem
by writing JNI methods or by executing programs
that can do what you want - for example:

    Runtime.getRuntime.exec("chmod a+x myfile");
About | Sitemap | Contact