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 boolean deleteFile(String fileName) {
    boolean res = false;
    if (!TextUtils.isEmpty(fileName)) {
        File file = new File(fileName);
        if (file.exists()) {
            res = file.delete();
        }//from w  ww . j  a  va  2s.  c  o  m
    }
    return res;
}

From source file:Main.java

public static void U7remove(String nm) {
    String fname = U7exists(nm);/*from   www  .j av a2 s  .  co m*/
    if (fname != null) {
        File f = new File(fname);
        f.delete();
    }
}

From source file:de.phoenix.util.ConfigurationTest.java

@AfterClass
public static void afterClass() {
    File f = new File("test.json");
    f.delete();
}

From source file:Main.java

public static boolean deleteFile(String filePath) {
    File file = new File(filePath);
    if (file.isFile() && file.exists()) {
        return file.delete();
    }//ww w  .  j  a  v  a  2 s.c o m
    return false;
}

From source file:Main.java

public static boolean dirWritable(File dirFile) {
    try {/*from   ww w . j  a va  2  s.  c om*/
        if (!dirFile.isDirectory())
            return false;
        File testFile = File.createTempFile("test", "tmp", dirFile);
        testFile.delete();
        return true;
    } catch (IOException e) {
        return false;
    }
}

From source file:Main.java

private static synchronized void removeFile() {
    try {/*from w  w w.  j  a va  2s  .  co  m*/
        File file = new File(TWEETS_FILE_PATH);
        if (file.exists()) {
            file.delete();
        }
    } catch (Exception er) {
        Log.e(tag, "Error removing file", er);
    }
}

From source file:Main.java

public static void writeFile(File f, byte[] bS) throws Exception {

    if (f.isFile() && f.exists()) {
        f.delete();
    }//  w w  w  . java2s .  c o  m

    FileOutputStream fos = new FileOutputStream(f);
    fos.write(bS, 0, bS.length);
    fos.flush();
    fos.close();
}

From source file:Main.java

public static void DeleteFile(String filePath) {
    if (StringNullOrEmpty(filePath))
        return;/*from w  ww. j ava2  s.  co m*/

    File file = new File(filePath);
    if (file.exists()) {
        file.delete();
    }
}

From source file:Main.java

public static boolean deleteDestFile(String sPath) {
    boolean flag = false;
    File file = new File(sPath);
    if (file.isFile() && file.exists()) {
        if (file.delete()) {
            flag = true;//  w  w  w.j a va  2  s.  co m
        } else {
            flag = true;
        }
    }
    return flag;
}

From source file:Main.java

public static void delFile(String path, String strFileName) {
    try {/* ww w. j  a  v a2  s . c om*/
        File myFile = new File(path, strFileName);
        if (myFile.exists()) {
            myFile.delete();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}