Solved

Create directory using Java with certain permissions

Posted on 2008-10-31
3
1,085 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
Comment Utility
No - you'd have to Runtime.exec chmod
0
 

Accepted Solution

by:
rohit_kapil earned 0 total points
Comment Utility
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
Comment Utility
Yes - sorry - didn't think of that for some reason!
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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 …
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 …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

728 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

10 Experts available now in Live!

Get 1:1 Help Now