• Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing File Permissions in JDK 1.5

 
Kamal Ahmed
Ranch Hand
Posts: 91
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I would appreciate if anyone can give me a working example / Clue on How to get around changing File Permissions from Read Only to Writable in JDK 1.5 on Windows.

Thanks,
-Kamal.
 
Jan Cumps
Bartender
Posts: 2614
14
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's not available in the 1.5 APIs

JSR-203 proposes better attribute support, but is planned for Java 7.

You could exec() Window's attrib command, or write a JNI wrapper around the win32 SetFileAttributes function.

Regards, Jan

[edit: the JIFI installation toolkit has a class WindowsFileService, with method setAttributes()]
[ May 22, 2007: Message edited by: Jan Cumps ]
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JDK 6 did add some simple method to the File class, such as setReadOnly() and setWritable(). Doesn't help you much if you have to use 1.5, but if there's any flexibility in that requirement, it's worth considering.
 
Arthur Buliva
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or you may use Runtime.getRuntime().exec() method to pass the values



to your file/folder.

For example with meanings:




and + setting the attribute and - removing it.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!