[
https://issues.apache.org/jira/browse/IO-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17800126#comment-17800126
]
Elliotte Rusty Harold commented on IO-413:
------------------------------------------
This seems unlikely to be very helpful. deleteOnExit is unlikely to succeed if
a straight delete fails, and if a client wants to try that it's easy enough to
set deleteOnExit on the file object themselves. This class is quite large
already, and I'd prefer not clutter it further with methods of limited utility.
I suggest won't fixing this issue.
> deleteQuietly(File) should try to closeOnDelete too
> ---------------------------------------------------
>
> Key: IO-413
> URL: https://issues.apache.org/jira/browse/IO-413
> Project: Commons IO
> Issue Type: Improvement
> Components: Utilities
> Reporter: David Mollitor
> Priority: Minor
>
> Something like...
> {code}
> public static boolean deleteQuietly(final File file, final boolean
> deleteOnExit) {
> boolean fileDeleted = false;
> if (file == null) {
> return false;
> }
> try {
> if (file.isDirectory()) {
> cleanDirectory(file);
> }
> } catch (final Exception ignored) {
> }
> try {
> fileDeleted = file.delete();
> } catch (final Exception ignored) {
> return false;
> }
> if (deleteOnExit && !fileDeleted)
> {
> file.deleteOnExit();
> }
> return fileDeleted;
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)