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:com.sshtools.common.util.ShutdownHooks.java

public static synchronized void exit(final boolean exit) {
    Iterator ifiles = files.iterator();
    while (ifiles.hasNext()) {
        String file = (String) ifiles.next();
        File f = new File(file);
        if (f != null & f.exists()) {
            f.delete();
        }//www  . j a  va2  s  .  co m
    }
    Iterator icodes = codes.iterator();
    Notif n = new Notif(codes.size());
    while (icodes.hasNext()) {
        Runnable code = (Runnable) icodes.next();
        try {
            Thread t = new Helper(code, n);
            t.start();
            if (!exit)
                t.join();
        } catch (IllegalThreadStateException e) {
            log.error("Exception", e);
        } catch (InterruptedException e) {
            log.error("Exception", e);
        }
    }

    files = new LinkedList();
    codes = new LinkedList();

    if (exit)
        n.start();
}

From source file:com.storageroomapp.client.util.FileUtil.java

static public void deleteFileTree(File file) {
    if (file.isDirectory()) {
        if (file.list().length == 0) {
            file.delete();
        } else {// ww  w  .  j  a  va  2  s  .  com
            String files[] = file.list();
            for (String cur : files) {
                File fileDelete = new File(file, cur);
                deleteFileTree(fileDelete);
            }
            if (file.list().length == 0) {
                file.delete();
            }
        }
    } else {
        file.delete();
    }
}

From source file:at.ac.uniklu.mobile.sportal.Studentportal.java

public static void clearCaches(Context applicationContext) {
    getSportalClient().clearCache();/* w w w. j  a  v a2s.  co  m*/
    getStudentPortalDB().mutingPeriods_clear();

    // delete cached profile pictures
    File privateFilesDir = applicationContext.getFilesDir();
    for (File privateFile : privateFilesDir.listFiles()) {
        privateFile.delete();
    }

    // delete application cache (webview etc...)
    Utils.clearAppCache(applicationContext);
}

From source file:net.refractions.udig.document.source.ShpDocUtils.java

/**
 * Deletes a file from the file system./*w ww .j  ava 2  s  .  c o  m*/
 * 
 * @param file
 * @return true if successful, otherwise false
 */
public static boolean deleteFile(File file) {
    if (file != null) {
        if (file.exists()) {
            return file.delete();
        }
    }
    return false;
}

From source file:net.sf.sripathi.ws.mock.util.FileUtil.java

public static boolean deleteFolder(String name) {

    File file = new File(name);

    if (file.isDirectory()) {
        deleteFiles(file);/*from w w w  . j  av  a2 s  . c  o m*/
    }

    return file.delete();
}

From source file:Main.java

@SuppressWarnings("unused")
public static boolean deleteFile(File file) {
    if (file == null || !file.exists()) {
        return true;
    }/*from w  w  w. j  ava2s .  c o  m*/

    if (file.isDirectory()) {
        cleanDir(file);
    }
    return file.delete();
}

From source file:Main.java

public static boolean isFileValid(File f) {
    if (!f.exists()) {
        try {//w ww .  j  a va2 s .c o  m
            f.createNewFile();
        } catch (IOException e) {

            return false;
        }
        f.delete();
    }
    return true;
}

From source file:com.jdom.util.properties.PropertiesUtil.java

public static void writePropertiesFile(Properties properties, File outputFile) throws IllegalArgumentException {
    OutputStream os = null;/*from  ww  w.ja  va  2 s. c  om*/

    try {
        outputFile.delete();
        outputFile.getParentFile().mkdirs();
        outputFile.createNewFile();
        os = new FileOutputStream(outputFile);

        properties.store(os, "");
    } catch (IOException e) {
        throw new IllegalArgumentException(e);
    } finally {
        IOUtils.closeQuietly(os);
    }
}

From source file:Main.java

static void deleteFile(File f, boolean toDeleteSelf) {
    if (f.isDirectory()) {
        for (File child : f.listFiles())
            deleteFile(child, true);/*from w  ww .j av a 2  s. c om*/
    }
    if (toDeleteSelf)
        f.delete();
}

From source file:com.groupon.odo.bmp.Utils.java

private static File getKeyStoreRoot(String hostname) throws Exception {
    File root = new File("seleniumSslSupport" + File.separator, hostname);
    if (!root.exists()) {
        // create it and get the root cert
        root.delete();
        root.mkdirs();/*from   ww w .j ava  2 s.c  o m*/
        com.groupon.odo.proxylib.Utils.copyResourceToLocalFile("cybervillainsCA.jks",
                root.getAbsolutePath() + File.separator + "cybervillainsCA.jks");
        com.groupon.odo.proxylib.Utils.copyResourceToLocalFile("cybervillainsCA.cer",
                root.getAbsolutePath() + File.separator + "cybervillainsCA.cer");
    }

    return root;
}