JDK-4151287 : java.io.File: Add copyTo, rmDir
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.6,1.1.7,1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic,windows_nt
  • CPU: generic,x86
  • Submitted: 1998-06-22
  • Updated: 2002-04-27
  • Resolved: 2002-04-27
Related Reports
Relates :  
Description

Name: paC48320			Date: 06/22/98


The java.io.File class could use some additional methods
to make it more pratical for applications:

  - copyTo()
  - rmDir()

I've read thru some of the bugs which have been submitted for these
requests and they are all closed.  These methods could be implemented
by developers, but it is absolutely preposterous that these bugs have
been closed suggesting that developers write these methods.  

Copying, deep copying, and deep removing *should* be included in
File because they should be native calls into the operating system. 
The fact that the File API doesn't expose these basic operations
seems like a bug to me.

So please please aid those of developing real applications wit
 Java.  It is impossible to write any application which uses the
file system without using native methods, or implementing OS
functions in Java.
(Review ID: 33754)
======================================================================

Name: krT82822			Date: 09/23/99


Copy, move and delete are file operations that are provided by
every class library I've ever seen.  If a class library supports
one of these operations it supports all three of them.  Except
Java.

If you want to only provide two operations then make it copy and
delete not move and delete.  You can accomplish a move using a
copy followed by a delete (albeit an inefficient move) but you
can not accomplish a copy using any combination of move and
delete.

You support almost every other basic file operation as well as
some not so basic operations, why not this one?
(Review ID: 95648)
======================================================================

Comments
WORK AROUND Name: paC48320 Date: 06/22/98 Native methods ====================================================================== Name: krT82822 Date: 09/23/99 Write a native method on each platform you wish to support which detracts from the advantages of using Java. (Review ID: 95648) ======================================================================
11-06-2004

EVALUATION rmDir() can be achieved by a File.delete() call on a directory. copyTo() can be achieved by reading and writing the file out. benedict.gomes@Eng 1998-06-29 copyTo functionality can be achieved using NIO.
29-06-1998