Solved

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

Posted on 2008-06-17
7
2,364 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 250 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

863 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

Need Help in Real-Time?

Connect with top rated Experts

28 Experts available now in Live!

Get 1:1 Help Now