Example usage for java.io File delete

List of usage examples for java.io File delete

Introduction

In this page you can find the example usage for java.io File delete.

Prototype

public boolean delete() 

Source Link

Document

Deletes the file or directory denoted by this abstract pathname.

Usage

From source file:Main.java

public static void deleteFile(String filename) {
    File file = new File(filename);
    if (file.exists()) {
        file.delete();
    }/* ww w. j a va 2 s.co m*/
}

From source file:Main.java

public static void deleteZoomImg(String path) {
    File file = new File(path);
    if (file.exists()) {
        file.delete();
    } else {// w w w . ja va 2 s.  c om
        return;
    }
}

From source file:Main.java

public static void freeFileLock(FileLock fl, File file) {
    if (file != null) {
        file.delete();
    }//www .  j a v a2s .  c o  m

    if (fl != null && fl.isValid()) {
        try {
            fl.release();
        } catch (IOException var3) {
            ;
        }

    }
}

From source file:Main.java

public static void deleteFile(String fullName) {
    File file = new File(fullName);
    if (file.exists()) {
        file.delete();
    }//from   ww w  . ja v a 2 s. co  m
}

From source file:Main.java

private static void deleteImageFromLocal(String imagePath) {
    File file = new File(imagePath);
    if (file.exists()) {
        file.delete();
    }//from   w ww.  j av a  2s . c o m
}

From source file:Main.java

public static boolean deleteFile(String path) {
    File file = new File(path);
    if (file.exists()) {
        file.delete();
        return true;
    }/*from   ww  w. ja  v a  2s  . c  o  m*/
    return false;
}

From source file:Main.java

public static void deleteFile(Uri uri) {
    File f = new File(uri.getPath());
    if (f.exists()) {
        f.delete();
    }//w  w w  .jav a2s.c  o m

}

From source file:Main.java

public static void deleteObject(Context context, String fileName) {
    String filePath = context.getFilesDir().getPath() + "/" + fileName;
    File file = new File(filePath);
    if (file.exists()) {
        file.delete();
    }//from ww w .j a  v a2 s .c  om
}

From source file:Main.java

public static void delete(File file) {
    try {/* w w  w . j  a v  a2s.  c  o  m*/
        if (file.exists())
            file.delete();
    } catch (Exception e) {
    }
}

From source file:Main.java

private static void RecursionDeleteFile(File file) {
    if (file.isFile()) {
        file.delete();
        return;/*from  www . j  ava 2 s.c  om*/
    }
    if (file.isDirectory()) {
        File[] childFile = file.listFiles();
        if (childFile == null || childFile.length == 0) {
            file.delete();
            return;
        }
        for (File f : childFile) {
            RecursionDeleteFile(f);
        }
        file.delete();
    }
}