United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-4167472 : File.setReadOnly() should take a boolean argument indicating writability

Details
Type:
Enhancement
Submit Date:
1998-08-19
Status:
Resolved
Updated Date:
2005-11-03
Project Name:
JDK
Resolved Date:
2005-09-04
Component:
core-libs
OS:
generic,windows_95
Sub-Component:
java.io
CPU:
x86,generic
Priority:
P4
Resolution:
Fixed
Affected Versions:
1.2.0,1.3.0
Fixed Versions:

Related Reports

Sub Tasks

Description
Name: diC59631			Date: 08/19/98


Why not :

  java.io.File.setReadOnly(boolean mode)

to be able to set it true/false as for a lock-file
mechanism ?
(Review ID: 37210)
======================================================================

Name: rmT116609			Date: 11/20/2000


java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Server VM (build 2.0fcs-E, mixed mode)


in the java.io.class there is a method to make a file read only.
however this can't be undone. we need a methos like setReadOnly(boolean).
calling this method with a false argument should make the file modifiable.
we also need a method isReadOnly() to test this condition.
thanks
(Review ID: 112499)
======================================================================

Name: rmT116609			Date: 02/08/2001


java version "1.3.0"


java.io.File class can set read-only attribute on a file
(with setReadOnly() method) but it cannot clear it. If a
Java program encounters a read-only file which it needs
to write or delete, it can only do that using JNI. It's
also unable to undo the effect of previous setReadOnly()
call if it makes one. IMO there should be a method like
setReadOnly(boolean) so that setReadOnly(false) would make
the file writeable or throw an IOException is such operation
is not allowed
(Review ID: 116607)
======================================================================

                                    

Comments
EVALUATION

The java.io.File class has a setReadOnly operation but no corresponding way to
make a file writable because it is not clear how to specify the latter
operation.  In particular, on multi-user systems you have to answer the
question of "writable by whom?"  Even to ask this question requires dealing
with user identities, which is not something that the Java platform is yet
capable of doing.  That will likely change in a future feature release, at
which time we'll revisit this issue.

In the absence of a way to make an existing file writable, you can always delete
the read-only file and rewrite a new, writable version.  This is what many
source-code-control systems do anyway.

-- mr@eng 1998/10/30

Adding following methods in Mustang
setWritable(boolean writable, boolean ownerOnly);	    	
setReadable(boolean readable, boolean ownerOnly)	    	
setExecutable(boolean executable, boolean ownerOnly);	    	
setExecutable(boolean executable);	    	
setReadable(boolean readable);	    	
setWritable(boolean writable);	    	
canExecute();
                                     
2004-09-28



Hardware and Software, Engineered to Work Together