Solved

Create directory using Java with certain permissions

Posted on 2008-10-31
3
1,095 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

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

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…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
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:

696 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