«« Pat Myself on the Feedback? id3v2 throws UnsupportedOperationException »»
blog header image
The Java Recycle Bin RFE I Sent to Sun

This is the submission text verbatim, except that the email addresses have been somewhat spam-protected, the long link at the bottom incorportated into the text and some formatting to clean it up a bit -- Ryan

Update 6:39 AM Friday: here's a link to this RFE, though the email said that it may take a few days to show up. You also need a login to access the bug database.

From: IncidentDaemonATsunDOTcom
Subject: Your Report (Review ID: 290373) - java.io.File: move to Recycle Bin
Date: July 29, 2004 10:00:22 PM EDT
To: ryanATaudiomanDOTorg

************************************************
Your report has been assigned an internal review ID of: 290373

This review ID is NOT visible on the "Java Developer Connection" (JDC).

We greatly appreciate your interest in improving the quality
of Java(tm) Technology from Sun Microsystems.

Please be aware that the large volume of reports we receive
sometimes prevents us from responding individually to each
message.

We currently have a three week response time for responding to
Bug Reports. If the information is determined to be a new bug,
or a duplicate of a known bug, you will receive a followup email
containing a seven digit bug number. You may search for this bug
number on the "Java Developer Connection" (JDC) at this URL:
http://developer.java.sun.com/developer/bugParade/index.html.

If you just reported an issue that could have a major
impact on your project and you require a response,
please consider purchasing one of the support offerings
at this URL:
http://java.sun.com/support/index.html


---------------------------------------------------------------


dateCreated: Thu Jul 29 20:00:18 MDT 2004
type: rfe
cust_name: Ryan Lowe
cust_email: ryanATaudiomanDOTorg
jdcid: ryanATaudiomanDOTorg
status: Waiting
category: java
subcategory: classes_io
company: AudioMan
release: 1.4.2
hardware: x86
OSversion: win_xp
priority: 4
synopsis: java.io.File: move to Recycle Bin
description:

A DESCRIPTION OF THE REQUEST :

PLEASE NOTE: this problem is not specific to Windows. This RFE is to add a method to the Java spec, so that a cross-platform solution is available to Java developers.

java.io.File lacks a method to send a file to the operating system's Recycle Bin or Trash Can. Since the "Recycle Bin" paradigm has been adopted by several major operating systems (Windows, Mac OS X and Linux) it would be great to have a method in the File class to do this.

This RFE does not suggest changing the delete() method in any way. In RFE bug 4641147 that type of enhancement was suggested and I agree that will "break crossplatform compatibility".

Instead this RFE suggests that a new method be made, named something like moveToRecycleBin() or moveToTrash() in java.io.File. This method would use OS-specific calls to send the file to the Recycle Bin so it can be restored/undeleted by the user.

JUSTIFICATION :

Many modern operating systems support the "Recycle Bin" paradigm. In order for Java to succeed on the desktop, J2SE developers need to have desktop-specific methods available to us.

In desktop software, there is a need sometimes for a simulated "file browser" in a view where file operations take place like rename/move/open/delete. It's quite common to have this in a IDE. In these file browsers, user's expect the operations to act just like the native file browser available to them in the desktop environment. On Windows, for example, this is Windows Explorer.

So in these file browsers when a user deletes a file, they expect it to show up in the Recycle Bin. This is typical for Windows applications like Visual Studio .NET 2003.

EXPECTED VERSUS ACTUAL BEHAVIOR :

EXPECTED -

A call to moveToRecycleBin() or moveToTrash() would move the file from its current location to the operating system-specific Recycle Bin where it may be successfully recovered by the user.

Like delete(), the method could return boolean indicating success or failure.

On platforms where a move to Recycle Bin may not make sense (like on some Unix operating systems without a desktop environment or J2EE), then a simple call-through to delete() would suffice because that is the expected behaviour on a platform without a Recycle Bin.

ACTUAL -

Since there are operating system specific tasks that need to be done during the move to the Recycle Bin, this ability is currently not available to Java developers. It is not as simple as moving the file to the (hidden) Recycle Bin directory on Windows, for example.

On Windows, the Win32 API shell function SHFileOperation() does a move to Recycle Bin. This would have to be called via JNI from Java.

workaround:
comments: (company - AudioMan , email - ryanATaudiomanDOTorg)

Posted at July 29, 2004 at 10:16 PM EST
Last updated July 29, 2004 at 10:16 PM EST
Comments
Google
 
Search scope: Web ryanlowe.ca