I have deleted some Files in a Java Program, but I was surprised to see them missing in Recycle Bin? I'm not using any of the IDEs, and is there any way to recover those files?
Asked
Active
Viewed 339 times
0
-
2The Recycle Bin is a special folder from the OS. Deleting files removes them from the hard disk completely. – Raildex Jun 29 '21 at 09:14
-
3No, but if you want to move files to Trash in the future,`java 9` has an API for it called [moveToTrash](https://docs.oracle.com/javase/9/docs/api/java/awt/Desktop.html#moveToTrash-java.io.File-). Below Java 9 you'll have to use JNI. – Coding Otaku Jun 29 '21 at 09:19
-
@CodingOtaku make that an answer, as many may search for such relative new and tiny functionality – Joop Eggen Jun 29 '21 at 09:48
-
@JoopEggen okay, I wrote one, I don't usually write answers, if it require more details/ corrections feel free to edit. – Coding Otaku Jun 29 '21 at 14:05
1 Answers
3
To Answer your question, No. Deleting files removes them from the hard disk completely.
But if you want to move files to Trash in the future, Java 9
has an API for it called moveToTrash.
Below Java 9
you'll have to use JNA or libraries that makes use of it like FileUtils
.
A related question in stackoverflow - Is it Possible with Java to Delete to the Recycle Bin?

Coding Otaku
- 453
- 7
- 17