File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Filewriter File permission Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Filewriter File permission" Watch "Filewriter File permission" New topic

Filewriter File permission

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492

Am just creating a new file using the below code. But it’s creating the file with permission “rw-r------”

But I need “rw-r-r-----”

Please help me to change the permission

Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

That's defined by the umask. You can either change the umask or if you aren't allowed to do that, you can call File.setReadable(true, false) after creating the file.

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Sorry, Our weblogic JVM version is 1.5. Please give a alternate way..
Rob Spoor

Joined: Oct 27, 2005
Posts: 19914

You can either use JNI, or use ProcessBuilder to execute the chmod command on your file.

How To Ask Questions How To Answer Questions
I agree. Here's the link:
subject: Filewriter File permission