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.xebialabs.deployit.cli.ext.mustachify.io.Files2.java

/**
 * Returns the path to an (almost certainly) non-existent file in the default temporary 
 * directory. The file itself is <em>not</em> created.
 * //from w  w  w  .  j ava 2 s  .  c om
 * Due to the small possibility that another process claims the name before it can
 * be used, callers may wish to check for existence using {@link File#exists()} to
 * be sure.
 */
public static String getTempFilePath(String basename, String ext) throws IOException {
    File tempFile = File.createTempFile(basename, ext);
    String tempFilePath = tempFile.getPath();
    tempFile.delete();
    return tempFilePath;
}

From source file:jeeves.utils.IO.java

public static void delete(File file, boolean throwException, ServiceContext context) {
    if (!file.delete() && file.exists()) {
        if (throwException) {
            throw new RuntimeException("Unable to delete " + file.getAbsolutePath());
        } else {//from ww w  . j av  a2  s  .com
            context.warning("Unable to delete " + file.getAbsolutePath());
        }
    }
}

From source file:Main.java

public static void DeleteBookmarkedHtmlResource(File fileOrDirectory) {
    try {//  w w  w  . j a  v a2 s  .  co  m
        if (fileOrDirectory.isDirectory())

            for (File child : fileOrDirectory.listFiles())
                DeleteBookmarkedHtmlResource(child);
        fileOrDirectory.delete();

    } catch (Exception e) {

        e.printStackTrace();
    }
}

From source file:be.ac.ua.comp.scarletnebula.core.KeyManager.java

public static void deleteKey(final String providerName, final String keyname) {
    final File keyFile = new File(getKeyFilename(providerName, keyname));

    if (keyFile.exists()) {
        keyFile.delete();
    }//from w  w  w  . j  a v a  2s . c o m
}

From source file:com.jaeksoft.searchlib.util.FileUtils.java

public final static File createTempDirectory(String prefix, String suffix) throws IOException {
    final File temp;

    temp = File.createTempFile(prefix, suffix);

    if (!temp.delete())
        throw new IOException("Could not delete temp file: " + temp.getAbsolutePath());

    if (!temp.mkdir())
        throw new IOException("Could not create temp directory: " + temp.getAbsolutePath());

    return temp;//from  www .  j a  v a  2s . com
}

From source file:net.openhft.chronicle.logger.logback.LogbackTestBase.java

protected static void deleteIndexedFiles(String testId) {
    String basePath = basePath(testId);
    String[] arr$ = new String[] { basePath + ".data", basePath + ".index" };
    int len$ = arr$.length;

    for (int i$ = 0; i$ < len$; ++i$) {
        String name = arr$[i$];/*w w w  .j  av  a 2  s  . co  m*/
        File file = new File(name);
        file.delete();
    }
}

From source file:net.fabricmc.installer.installer.ServerInstaller.java

public static void install(File mcDir, String version, IInstallerProgress progress) throws IOException {
    File fabricJar = new File(mcDir, Reference.NAME_FABRIC_LOADER + "-" + version + ".jar");
    if (fabricJar.exists()) {
        fabricJar.delete();
    }/* ww w  .j  a  va 2s  .  c o m*/

    progress.updateProgress(Translator.getString("install.server.downloadFabric"), 5);
    FileUtils.copyURLToFile(new URL(MavenHandler.getPath(Reference.MAVEN_SERVER_URL, Reference.PACKAGE_FABRIC,
            Reference.NAME_FABRIC_LOADER, version)), fabricJar);
    install(mcDir, version, progress, fabricJar);
}

From source file:com.youTransactor.uCube.LogManager.java

public static void deleteLogs() {
    File logDir = context.getDir(LOG_DIR, Context.MODE_PRIVATE);

    if (!logDir.exists()) {
        return;//from   w w w  . j  a  v  a2s  .  c om
    }

    boolean wasEnabled = false;

    if (out != null) {
        synchronized (mOut) {
            wasEnabled = true;
            out.close();
            out = null;
        }
    }

    for (File file : logDir.listFiles()) {
        file.delete();
    }

    setEnabled(wasEnabled);
}

From source file:net.padaf.preflight.TestIsartorValidationFromClasspath.java

@BeforeClass
public static void beforeClass() throws Exception {
    validator = new PdfAValidatorFactory().createValidatorInstance(PdfAValidatorFactory.PDF_A_1_b);

    String irp = System.getProperty("isartor.results.path");
    if (irp != null) {
        File f = new File(irp);
        if (f.exists() && f.isFile()) {
            f.delete();
            isartorResultFile = new FileOutputStream(f);
        } else if (!f.exists()) {
            isartorResultFile = new FileOutputStream(f);
        } else {//from w w w  .j ava2  s . co m
            throw new IllegalArgumentException("Invalid result file : " + irp);
        }
    }
}