Java Delete Temp File deleteTempFiles()

Here you can find the source of deleteTempFiles()

Description

delete Temp Files

License

Open Source License

Declaration

public static void deleteTempFiles() 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.File;

public class Main {
    private static final String HOME = System.getProperty("user.home");
    private static final String APP_DIR_NAME = ".OpenLaTeXStudio";
    private static final String PREVIEW_SOURCE_FILENAME = "preview.tex";
    private static final String PREVIEW_PDF_FILENAME = "preview.pdf";

    public static void deleteTempFiles() {
        File source = new File(getTempSourceFile());
        File tmpPdf = new File(getTempPDFFile());
        if (source.exists()) {
            source.delete();/*w  ww.  j av  a2  s.c o  m*/
        }
        if (tmpPdf.exists()) {
            tmpPdf.delete();
        }
    }

    public static String getTempSourceFile() {
        return getAppDirectory().concat(File.separator).concat(PREVIEW_SOURCE_FILENAME);
    }

    public static String getTempPDFFile() {
        return getAppDirectory().concat(File.separator).concat(PREVIEW_PDF_FILENAME);
    }

    public static String getAppDirectory() {
        File tempDir = new File(HOME + File.separator + APP_DIR_NAME);
        if (!tempDir.exists()) {
            tempDir.mkdir();
        }
        return tempDir.getAbsolutePath();
    }
}

Related

  1. deleteTempFile()
  2. deleteTempFile(File f)
  3. deleteTempFile(final File tempFile)
  4. deleteTempFile(String fileId)
  5. deleteTempFiles()
  6. deleteTempFiles()
  7. deleteTempFiles()
  8. deleteTempFiles(final File workFolder)