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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
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
All Courses

From novice to tech pro — start learning today.