Java Delete File deleteFile(String fileName)

Here you can find the source of deleteFile(String fileName)

Description

delete File

License

Open Source License

Declaration

public static void deleteFile(String fileName) throws IOException 

Method Source Code

//package com.java2s;
/*//from   www .  jav a 2s .com
* Copyright (c) 2010-2012 Research In Motion Limited. All rights reserved.
*
* This program and the accompanying materials are made available
* under  the terms of the Apache License, Version 2.0,
* which accompanies this distribution and is available at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* To use this code further you must also obtain a valid copy of
* InstallAnywhere 8.0 Enterprise/resource/IAClasses.zip
* Please visit http://www.flexerasoftware.com/products/installanywhere.htm for the terms.
* 
* Additionally, for the Windows(R) installer you must obtain a valid copy of vcredist_x86.exe
* Please visit http://www.microsoft.com/en-us/download/details.aspx?id=29 for the terms.
* 
*/

import java.io.File;

import java.io.IOException;

public class Main {
    public static void deleteFile(String fileName) throws IOException {
        deleteFile(new File(fileName));
    }

    public static void deleteFile(File file) throws IOException {
        if (file.exists() && file.isFile()) {
            if (!file.delete()) {
                System.out.println("Fail to delete file:" + file.getCanonicalPath());
            }
        }
    }
}

Related

  1. deleteFile(String filename)
  2. deletefile(String fileName)
  3. deleteFile(String FileName)
  4. deleteFile(String fileName)
  5. deleteFile(String filename)
  6. deleteFile(String fileName)
  7. deleteFile(String fileName)
  8. deleteFile(String fileName)
  9. deleteFile(String fileName)