Is it possible with Java to delete to the Recycle

2019-01-22 18:25发布

Java is the key here. I need to be able to delete files but users expect to be able to "undelete" from the recycle bin. As far as I can tell this isn't possible. Anyone know otherwise?

8条回答
你好瞎i
3楼-- · 2019-01-22 18:57

Ten years later, with Java 9, finally there is a builtin way to move files to the Trash Bin

java.awt.Desktop.moveToTrash(java.io.File):

public boolean moveToTrash​(File file)

Moves the specified file to the trash.

Parameters:

file - the file

Returns:

returns true if successfully moved the file to the trash.

The availability of this feature for the underlying platform can be tested with Desktop.isSupported​(Desktop.Action.MOVE_TO_TRASH).

查看更多
登录 后发表回答