-
Enhancement
-
Resolution: Fixed
-
P2
-
1.0, 1.0.2
-
1.1
-
sparc
-
generic, solaris_2.4
-
Verified
Fixed in 1.1 - File.delete() removes directories which are empty.
-------------------------------------
FIle.delete() only removes files, not directories. There is currently no way
to remove a directory until this is fixed.
--------------------------------------
In a shell, removing a file (rm) is intentionally different from removing
a directory (rmdir) and further the directory usually must be empty (without
a flag). This prevents disaster, and I believe that the semantic difference
ought to be preserved in the java API. So I recommend a method rmdir() be
added to the File class interface.
The upcoming 1.0.2 release is only bug fixes, with no changes to existing API.
Any changes to API will be released in 1.1.
-Dave Brown
###@###.###
The description field as copied from bug report 1242632 follows:
From ###@###.### Mon Mar 18 15:55:00 1996
Date: Mon, 18 Mar 1996 15:52:24 -0800
From: ###@###.### (Arthur van Hoff)
To: pavani@Eng
Subject: File.delete()
Mime-Version: 1.0
Hi Pavani,
It is currently impossible to delete directories from Java.
The delete() method in java.io.File does not delete the directory
when the File object refers to a directory (even when it is empty).
This leaves no alternative way to delete a directory.
Can you please file a bug against this? It would really help us
if this gets fixed. I've attached a test program. Thanks!
Have fun,
Arthur van Hoff
-----Test--------------------
import java.io.File;
public class Test {
public static void main(String argv[]) {
File f = new File(argv[0]);
System.out.println("mkdir = " + f.mkdir());
System.out.println("delete = " + f.delete());
}
}
-------------------------------------
FIle.delete() only removes files, not directories. There is currently no way
to remove a directory until this is fixed.
--------------------------------------
In a shell, removing a file (rm) is intentionally different from removing
a directory (rmdir) and further the directory usually must be empty (without
a flag). This prevents disaster, and I believe that the semantic difference
ought to be preserved in the java API. So I recommend a method rmdir() be
added to the File class interface.
The upcoming 1.0.2 release is only bug fixes, with no changes to existing API.
Any changes to API will be released in 1.1.
-Dave Brown
###@###.###
The description field as copied from bug report 1242632 follows:
From ###@###.### Mon Mar 18 15:55:00 1996
Date: Mon, 18 Mar 1996 15:52:24 -0800
From: ###@###.### (Arthur van Hoff)
To: pavani@Eng
Subject: File.delete()
Mime-Version: 1.0
Hi Pavani,
It is currently impossible to delete directories from Java.
The delete() method in java.io.File does not delete the directory
when the File object refers to a directory (even when it is empty).
This leaves no alternative way to delete a directory.
Can you please file a bug against this? It would really help us
if this gets fixed. I've attached a test program. Thanks!
Have fun,
Arthur van Hoff
-----Test--------------------
import java.io.File;
public class Test {
public static void main(String argv[]) {
File f = new File(argv[0]);
System.out.println("mkdir = " + f.mkdir());
System.out.println("delete = " + f.delete());
}
}
- duplicates
-
JDK-1242632 File.delete does not work on directories.
- Closed
-
JDK-4017265 File.delete() does not work for directories on solaris
- Closed