Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2008-06-17
7
Medium Priority
?
2,565 Views
Last Modified: 2013-12-29
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
0
Comment
Question by:prain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 1000 total points
ID: 21802206
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
 

Author Comment

by:prain
ID: 21802333
is'nt there a direct Java way of doing that?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21802378
No. Java is platform independent, so would have no platform-dependent way of altering file perms
0
Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

 

Author Comment

by:prain
ID: 21802391
Ok. That' right. I will try this.
0
 

Author Closing Comment

by:prain
ID: 31467929
OK. That works Great!.  Thanks.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 21803985
:-)

Which way did you go in the end?
0
 

Author Comment

by:prain
ID: 21807006
I set the permissions using chmod 775  by Runtime.exe();
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question