Directory Permissions problem when using mkdir() of the File class

Hello,

I hava a Java application that creates directories using the mkdir() method of the File class. This is in UNIX. when the directory is created by madir() it has drwxr-xr-x permissions string by default. As you can see the user has r/w/ex permissions, and the group has only r/ex permissions and does not have 'write' permissions. Our requirement is, when this directory is created, we must give permissions to the group also for writing.

Since mkdir() defaults to drwxr-xr-x, how can I set the peremissions to be drwxrwxr-x so that the group will also have write permissions when the directory is created.

Thanks
prain
prainAsked:
Who is Participating?
 
CEHJConnect With a Mentor Commented:
Two ways i can think of

1. set the umask of the shell in which the java app is running to 0002 (man umask)
2. Runtime.exec a chmod after the fact
0
 
prainAuthor Commented:
is'nt there a direct Java way of doing that?
0
 
CEHJCommented:
No. Java is platform independent, so would have no platform-dependent way of altering file perms
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
prainAuthor Commented:
Ok. That' right. I will try this.
0
 
prainAuthor Commented:
OK. That works Great!.  Thanks.
0
 
CEHJCommented:
:-)

Which way did you go in the end?
0
 
prainAuthor Commented:
I set the permissions using chmod 775  by Runtime.exe();
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.