Java Delete File deleteFile(final File f, final int attempts, final long sleepTime)

Here you can find the source of deleteFile(final File f, final int attempts, final long sleepTime)

Description

delete File

License

Open Source License

Declaration

public static boolean deleteFile(final File f, final int attempts, final long sleepTime) 

Method Source Code

//package com.java2s;
/**/* ww  w.j  a v  a  2s.c  om*/
 * Copyright (C) 2015 BonitaSoft S.A.
 * BonitaSoft, 32 rue Gustave Eiffel - 38000 Grenoble
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation
 * version 2.1 of the License.
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
 * Floor, Boston, MA 02110-1301, USA.
 **/

import java.io.File;

public class Main {
    public static boolean deleteFile(final File f, final int attempts, final long sleepTime) {
        int retries = attempts;
        while (retries > 0) {
            if (f.delete()) {
                break;
            }
            retries--;
            try {
                Thread.sleep(sleepTime);
            } catch (final InterruptedException e) {
            }
        }
        return retries > 0;
    }
}

Related

  1. deleteFile(File file)
  2. deleteFile(File file)
  3. deleteFile(File file)
  4. deleteFile(File file)
  5. deleteFile(File source)
  6. deleteFile(final File file)
  7. deleteFile(final File file)
  8. deleteFile(final File file)
  9. deleteFile(final File file)