my dog learned polymorphism*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Filewriter File permission" Watch "Filewriter File permission" New topic
Author

Filewriter File permission

Meet Gaurav
Ranch Hand

Joined: Oct 08, 2008
Posts: 492
Hi

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
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Filewriter File permission
 
Similar Threads
Configure Jboss in Ant???
In Java program how to export data from database to text file
java.io.package
UNIXhow to ensure files created in a directory automatically has group "w" permission
File creation in Java