commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rajiv Jain (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (IO-413) deleteQuietly(File) should try to closeOnDelete too
Date Sat, 16 Jul 2016 14:23:20 GMT

    [ https://issues.apache.org/jira/browse/IO-413?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15380790#comment-15380790
] 

Rajiv Jain commented on IO-413:
-------------------------------

I will try to have a working fix for this.

> 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: BELUGA BEHR
>            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
(v6.3.4#6332)

Mime
View raw message