Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2008-06-17
7
Medium Priority
?
2,634 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

824 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