Name: js151677 Date: 07/30/2004
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, users 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.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shfileoperation.asp
(Incident Review ID: 290373)
======================================================================
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, users 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.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/functions/shfileoperation.asp
(Incident Review ID: 290373)
======================================================================
- relates to
-
JDK-4641147 File should support a way to delete to a trashcan, if supported by the OS
-
- Closed
-