Solved

Create directory using Java with certain permissions

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java JRE greater than 1.6 5 62
even odd program using while loop 3 40
arguments to jar 5 26
Java: How do I open the default windows program for a given file type 3 28
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…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

770 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