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 saveFile(Bitmap bm, String path, Bitmap.CompressFormat format) {
    if (bm == null || path == null)
        return false;
    File myCaptureFile = new File(path);
    if (myCaptureFile.exists()) {
        myCaptureFile.delete();
    }/*from w w w  .j  a v a  2  s. c o m*/
    try {
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(myCaptureFile));
        bm.compress(format, 80, bos);
        bos.flush();
        bos.close();
        return true;
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return false;
}

From source file:Main.java

public static void deleteFilesStartingWith(String string) {
    File specificFile = new File(string);
    File pFile = specificFile.getParentFile();
    if (pFile != null) {
        for (File f : pFile.listFiles()) {
            if (f.getName().startsWith(specificFile.getName())) {
                f.delete();
            }//from  w w  w .  j  a  v  a 2s  .  c o m
        }
    }
}

From source file:Main.java

public static void delDir(File dir) {
    try {// w  ww .jav a2  s . c o m
        if (dir != null) {
            delAllFiles(dir);
            dir.delete();
        }
    } catch (Exception e) {
    }
}

From source file:localSPs.BearDataShareAPI.java

public static void deleteFile(String fileName) {
    String newDir = ROOT_PATH;//  w  ww .  j  a  v  a  2  s.c  o m

    java.io.File file = new java.io.File(newDir + fileName);
    file.delete();

}

From source file:net.estinet.gFeatures.Feature.Gliders.Enable.java

public static void onEnable() {
    Bukkit.getLogger().info("[Gliders] Enabled :D");
    ch.setupConfig();/*from  www .  ja  v  a 2  s  .c  om*/

    File f = new File("plugins/gFeatures/Gliders/Gliders2");
    File fz = new File("./Gliders2");

    fz.delete();
    try {
        FileUtils.copyDirectory(f, fz);
    } catch (IOException e) {
        e.printStackTrace();
    }
    f = new File("plugins/gFeatures/Gliders/Gliders1");
    fz = new File("./Gliders1");
    fz.delete();
    try {
        FileUtils.copyDirectory(f, fz);
    } catch (IOException e) {
        e.printStackTrace();
    }

    Capture c = new Capture();
    c.loop();
    Bukkit.getScheduler().scheduleSyncDelayedTask(Bukkit.getServer().getPluginManager().getPlugin("gFeatures"),
            () -> {
                WorldCreator cs = new WorldCreator("MinigameSpawn");
                Bukkit.getServer().createWorld(cs);

                WorldCreator cs1 = new WorldCreator("Gliders1");
                Bukkit.getServer().createWorld(cs1);

                WorldCreator cs2 = new WorldCreator("Gliders2");
                Bukkit.getServer().createWorld(cs2);

                ClioteSky.getInstance().send(new byte[0], "mghello", "Bungee");
            }, 40L);
    Bukkit.getScheduler()
            .scheduleSyncRepeatingTask(Bukkit.getServer().getPluginManager().getPlugin("gFeatures"), () -> {
                ConstantCheck cc = new ConstantCheck();
                cc.goThrough();
            }, 20L, 20L);
}

From source file:net.przemkovv.sphinx.Utils.java

public static void cleanupFilesystem(List<File> files) {
    if (files != null && !files.isEmpty()) {
        File parent_dir = files.get(0).getParentFile();
        for (File file : files) {
            file.delete();
        }/*from   ww  w . j av a  2  s.  co m*/
        parent_dir.delete();

    }
}

From source file:com.lunix.cheata.utils.file.FileManager.java

public static void deleteFile(String fileName) {
    try {/*from w ww .j  a v  a  2s . c om*/
        File file = new File(dir.getAbsolutePath(), fileName);
        file.delete();
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.heliosdecompiler.helios.utils.APKTool.java

public static void decodeResources(File input, File output) {
    try {//from   ww  w .  j a v  a 2s . co m
        Path temporaryDirectory = Files.createTempDirectory("apkresources");
        File directory = temporaryDirectory.toFile();
        Files.delete(temporaryDirectory);
        cmdDecode(input, directory);
        File original = new File(directory, "original");
        FileUtils.deleteDirectory(original);
        File apktool = new File(directory, "apktool.yml");
        apktool.delete();
        ZipUtil.pack(directory, output);
        FileUtils.deleteDirectory(directory);
    } catch (Exception e) {
        ExceptionHandler.handle(e);
    }
}

From source file:Main.java

/**
 * Delete directory you passed. the directory's child file and directory will be deleted too by recursive exploring.
 *///from   w  ww .j a  v a 2s.co m
public static void deleteAllFiles(File directory) {
    File[] files;

    files = directory.listFiles();
    files = files == null ? new File[0] : files;

    for (File file : files) {
        if (file.isDirectory())
            deleteAllFiles(file);
        else
            file.delete();
    }
    directory.delete();
}

From source file:Main.java

private static void delete(File file, StringBuilder sb) {
    long length = file.length();
    boolean deleted = file.delete();
    if (deleted) {
        sb.append(file.getAbsolutePath() + " length " + length + " bytes, deleted.\r\n");
    } else {/* w  ww  .ja v  a2 s .co m*/
        sb.append(file.getAbsolutePath() + " length " + length + " bytes, can't delete.\r\n");
    }
}