Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 4268151
Votes 0
Synopsis File.canWrite() and delete() improvements
Category java:classes_io
Reported Against 1.0.1 , 1.2.2
Release Fixed
State 6-Fix Understood, bug
Priority: 4-Low
Related Bugs 4313887
Submit Date 02-SEP-1999
Description


This is a problem that's been around since the inception of java.io 
and needs addressing.

The problem is that the interaction between java.io.File methods 
canWrite() and delete() is unclear.

On some platforms, delete() will fail if canWrite() is false,(e.g. WinNT), 
even if there is write access to the parent directory.

I suggest that EITHER the spec is changed to specify that delete() 
always fails if canWrite() is false (which will probably impact existing 
code running on Solaris), OR to specify that on some platforms, 
canWrite() may imply that delete() will fail.

The latter solution, despite the obviously platform dependence, is 
probably necessary to avoid breaking existing java.io code.  Then 
again, existing java.io code is already non-portable because of this 
issue.

Either way, this portability issue should be brought to the attention 
of developers in the documentation.
(Review ID: 94768) 
======================================================================




java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)

I want a method that says if I can write to a File.
File.canWrite() is not what I want.
It tells me if I can write to an existing file,
but gives no useful information if the file does
not exist.  If the file does not exist, I want to
know if I can create it.  I feel this is what
File.canWrite() should have done, but it is too
late to change the API.  So we need a new method.
Maybe call it "File.canCreateOrWrite()".
(Review ID: 110002)
======================================================================
Posted Date : 2005-08-25 16:30:27.0
Work Around
N/A
Evaluation
Reasonable request.  We could also consider adding a canDelete method so that
the question can be asked directly.  --   xxxxx@xxxxx   1999/10/28
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang