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 deleteFromFile(File file) {
    if (null != file && file.exists())
        file.delete();
}

From source file:Main.java

public static void deleteFile(String path) {
    File file = new File(path);
    if (file.exists())
        file.delete();
}

From source file:Main.java

public static boolean deleteFile(String filename) {
    if (filename == null) {
        return false;
    }/*w ww .  j  a  va 2s  .  co m*/
    try {
        File f = new File(filename);
        return f.delete();
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static void deleteFileByApkSaveName(String apkSaveName) {
    File file = new File(DOWNLOADPATH + apkSaveName + ".apk");
    file.delete();
}

From source file:Main.java

public static void deleteTempFile(String path) {
    File file = new File(path);
    if (file.exists()) {
        file.delete();
    }//from  w  w w.j  a  va 2 s  .  c  om
}

From source file:Main.java

public static void delectCardFile(String path) {
    File file = new File(path);
    if (file.exists()) {
        file.delete();
    }// w  w  w . j  av a2s.c  o  m
}

From source file:Main.java

public static void deleteFileByDirectory(File directory) {
    if (directory.exists() && directory.isDirectory()) {
        for (File file : directory.listFiles()) {
            file.delete();
        }/*from   w w w .j a  v a  2 s  .c o  m*/
    }
}

From source file:Main.java

public static void clearCache(Context context) {

    File cache = context.getCacheDir();
    String[] files = cache.list();
    for (String file : files) {
        File data = new File(cache.getPath() + "/" + file);
        data.delete();
    }//from w w w.  java  2  s .c  o  m
}

From source file:Main.java

/**
 * Clears the already stored file.//from  w  w w  .j a  va  2 s .c om
 */
public static void clearFileCache(String filename) {
    File file = new File(filename);

    if (file.exists() && file.delete()) {
        Log.d("GIJON", "Fichero local " + filename + " borrado");
    }
    return;
}

From source file:Main.java

public static void deleteFileOrThrow(File paramFile) throws IOException {
    if ((paramFile.exists()) && (!paramFile.delete()))
        throw new IOException("failed to delete file: " + paramFile);
}