Solved

Create directory using Java with certain permissions

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
diffSum example 4 50
ejb message driven bean mdb creation steps 2 23
running on tomcat not jboss eap 7.0 3 18
passing enum to a method 4 21
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

861 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