Java Delete File deleteFile(File file)

Here you can find the source of deleteFile(File file)

Description

delete File

License

Open Source License

Declaration

public static void deleteFile(File file) throws IOException 

Method Source Code

//package com.java2s;
/**/*from w  w w  .  j  a va2  s .  c  o  m*/
 * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved.
 * Licensed under the terms of the Eclipse Public License (EPL).
 * Please see the license.txt included with this distribution for details.
 * Any modifications to this file must keep this entire header intact.
 */

import java.io.File;

import java.io.FileNotFoundException;

import java.io.IOException;

public class Main {
    public static void deleteFile(File file) throws IOException {
        if (!file.exists())
            throw new FileNotFoundException(file.getAbsolutePath());

        if (!file.delete()) {
            throw new IOException("Delete operation failed when deleting: " + file);
        }
    }
}

Related

  1. deleteFile(File file)
  2. deleteFile(File file)
  3. deleteFile(File file)
  4. deleteFile(File file)
  5. deleteFile(File file)
  6. deleteFile(File file)
  7. deleteFile(File source)
  8. deleteFile(final File f, final int attempts, final long sleepTime)
  9. deleteFile(final File file)