?
Solved

Create directory using Java with certain permissions

Posted on 2008-10-31
3
Medium Priority
?
1,098 Views
Last Modified: 2012-05-05
Hi,
I'm using java.io.File.makedirs() to create a directory on HP Unix. It creates a directory with permissions inherited from the user profile set by the Sys Admin. Problem is the directory is created with only read permission to the group but I want to provide write permissions as well. The class File does not provide any method to create the directory and set its permissions i.e to override the default permissions.

Is there any other way to achieve this i.e. create a directory at set its permissions as per wish.

Thanks.
0
Comment
Question by:rohit_kapil
[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
  • 2
3 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 22854835
No - you'd have to Runtime.exec chmod
0
 

Accepted Solution

by:
rohit_kapil earned 0 total points
ID: 23066016
add the following lines to .profile or .login depending on the shell

umask 002

Or execute the java program from a shell script and add the above line before starting the program
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23066975
Yes - sorry - didn't think of that for some reason!
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

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…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

801 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