Java File Path Delete deleteFileIfExists(String path)

Here you can find the source of deleteFileIfExists(String path)

Description

delete File If Exists

License

Apache License

Declaration

public static boolean deleteFileIfExists(String path) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.File;

public class Main {
    public static boolean deleteFileIfExists(String path) {
        File f = new File(path);
        if (f.exists() && !f.isDirectory()) {
            return f.delete();
        }/*  w  w  w .  ja  v  a  2s .  c om*/
        return false;
    }
}

Related

  1. deleteFile(String strFolderPath, String strFileName)
  2. deleteFile(String strPath)
  3. deleteFile(String strPath, String fileName)
  4. DeleteFileFolder(String path)
  5. deleteFileFromDisk(String name, String path)
  6. deleteFileOrDirectory(String path)
  7. deleteFileOrDirectory(String path)
  8. deleteFiles(final File pathname)
  9. deleteFiles(String actionPath, String filePath)