类org.apache.commons.io.FileDeleteStrategy源码实例Demo

下面列出了怎么用org.apache.commons.io.FileDeleteStrategy的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jresume   文件: FileLocationValidator.java
@Override
public void validate(String name, String value) throws ParameterException {
    File file = new File(value);
    ParameterException exception = new ParameterException("File " + file.getAbsolutePath() + " does not exist and cannot be created.");
    try {

        if (!file.exists()) {
            boolean canCreate = file.createNewFile();
            if (canCreate) {
                FileDeleteStrategy.FORCE.delete(file);
            } else {
                throw exception;
            }

        }
    } catch (IOException exc) {
        throw exception;
    }

}
 
源代码2 项目: jresume   文件: FileLocationValidator.java
@Override
public void validate(String name, String value) throws ParameterException {
    File file = new File(value);
    ParameterException exception = new ParameterException("File " + file.getAbsolutePath() + " does not exist and cannot be created.");
    try {

        if (!file.exists()) {
            boolean canCreate = file.createNewFile();
            if (canCreate) {
                FileDeleteStrategy.FORCE.delete(file);
            } else {
                throw exception;
            }

        }
    } catch (IOException exc) {
        throw exception;
    }

}
 
源代码3 项目: Thunder   文件: HessianServletGenerator.java
private void forceDelete(int times) {
    if (times == 0) {
        return;
    }
    if (file.exists()) {
        try {
            FileDeleteStrategy.FORCE.delete(file);
        } catch (IOException e) {
            e.printStackTrace();
            try {
                TimeUnit.MILLISECONDS.sleep(1500);
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
            times--;
            forceDelete(times);
        }
    }
}
 
源代码4 项目: dependency-track   文件: v340Updater.java
public void executeUpgrade(AlpineQueryManager qm, Connection connection) throws SQLException {
    LOGGER.info("Recreating table PROJECT_PROPERTY");
    DbUtil.dropTable(connection, "PROJECT_PROPERTY"); // Will be dynamically recreated

    LOGGER.info("Deleting search engine indices");
    IndexManager.delete(IndexManager.IndexType.LICENSE);
    IndexManager.delete(IndexManager.IndexType.PROJECT);
    IndexManager.delete(IndexManager.IndexType.COMPONENT);
    IndexManager.delete(IndexManager.IndexType.VULNERABILITY);

    LOGGER.info("Deleting Dependency-Check work directory");
    try {
        final String DC_ROOT_DIR = Config.getInstance().getDataDirectorty().getAbsolutePath() + File.separator + "dependency-check";
        FileDeleteStrategy.FORCE.delete(new File(DC_ROOT_DIR));
    } catch (IOException e) {
        LOGGER.error("An error occurred deleting the Dependency-Check work directory", e);
    }
}
 
源代码5 项目: jresume   文件: Router.java
private void prepareEnvironment() throws IOException {
    if (Files.exists(Paths.get("data"))) {
        FileDeleteStrategy.FORCE.delete(new File("data"));
    }

    Files.createDirectory(Paths.get("data"));
}
 
源代码6 项目: jresume   文件: ResumeGenerator.java
private void extractResourcesFromJarFile() throws Exception {
    String classUrl = Main.class.getResource("Main.class").toString();

    URL url = Main.class.getResource("/resources.zip");
    //System.out.println("JAR Resource Zip URL: " + url.toString());
    InputStream inputStream = url.openStream();


    if (config.serverMode) {
        newResourceZip = config.serverInitialResourceZip;
        newResourceFolder = Paths.get("data", "resources").toFile();
    } else {
        newResourceZip = Paths.get(config.outputDirectory, "webresume-resources.zip").toFile();
        newResourceFolder = Paths.get(config.outputDirectory, config.resourceDirectory).toFile();
    }

    if (!newResourceFolder.exists()) {
        newResourceFolder.mkdirs();
    }

    if (newResourceZip.exists()) {
        FileDeleteStrategy.FORCE.delete(newResourceZip);
    }

    Files.copy(inputStream, newResourceZip.toPath());

    ZipFile zipFile = new ZipFile(newResourceZip);
    zipFile.extractAll(newResourceFolder.getAbsolutePath());
}
 
源代码7 项目: jresume   文件: Router.java
private void prepareEnvironment() throws IOException {
    if (Files.exists(Paths.get("data"))) {
        FileDeleteStrategy.FORCE.delete(new File("data"));
    }

    Files.createDirectory(Paths.get("data"));
}
 
源代码8 项目: jresume   文件: ResumeGenerator.java
private void extractResourcesFromJarFile() throws Exception {
    String classUrl = Main.class.getResource("Main.class").toString();

    URL url = Main.class.getResource("/resources.zip");
    //System.out.println("JAR Resource Zip URL: " + url.toString());
    InputStream inputStream = url.openStream();


    if (config.serverMode) {
        newResourceZip = config.serverInitialResourceZip;
        newResourceFolder = Paths.get("data", "resources").toFile();
    } else {
        newResourceZip = Paths.get(config.outputDirectory, "webresume-resources.zip").toFile();
        newResourceFolder = Paths.get(config.outputDirectory, config.resourceDirectory).toFile();
    }

    if (!newResourceFolder.exists()) {
        newResourceFolder.mkdirs();
    }

    if (newResourceZip.exists()) {
        FileDeleteStrategy.FORCE.delete(newResourceZip);
    }

    Files.copy(inputStream, newResourceZip.toPath());

    ZipFile zipFile = new ZipFile(newResourceZip);
    zipFile.extractAll(newResourceFolder.getAbsolutePath());
}
 
源代码9 项目: Asqatasun   文件: ProfileFactory.java
/**
 * 
 * @param firefoxProfile 
 */
public void shutdownFirefoxProfile(FirefoxProfile firefoxProfile) {
    try {
        if (deleteProfileData) {
            FileDeleteStrategy.FORCE.delete(new File(netExportPathMap.get(firefoxProfile)));
        }
    } catch (IOException ex) {
        Logger.getLogger(this.getClass()).error(ex);
    }
    netExportPathMap.remove(firefoxProfile);
}
 
源代码10 项目: JReFrameworker   文件: JReFrameworkerProject.java
private void clearProjectBuildDirectory(File buildDirectory) throws IOException {
	for(File file : buildDirectory.listFiles()){
		if(file.isDirectory()){
			File directory = file;
			clearProjectBuildDirectory(directory);
			directory.delete();
		} else {
			FileDeleteStrategy.FORCE.delete(file);
		}
	}
}
 
源代码11 项目: msf4j   文件: HttpResourceModelProcessor.java
private File createAndTrackTempFile(FormItem item) throws IOException {
    if (tmpPathForRequest == null) {
        if (Files.notExists(tempRepoPath)) {
            Files.createDirectory(tempRepoPath);
        }
        tmpPathForRequest = Files.createTempDirectory(tempRepoPath, "tmp");
    }
    Path path = Paths.get(tmpPathForRequest.toString(), item.getName());
    File file = path.toFile();
    StreamUtil.copy(item.openStream(), new FileOutputStream(file), true);
    fileCleaningTracker.track(file, file);
    fileCleaningTracker.track(tmpPathForRequest.toFile(), file, FileDeleteStrategy.FORCE);
    return file;
}
 
public void cleanup()
{
    try
    {
        FileDeleteStrategy.FORCE.delete(config.getDbStorageDirectory());
    }
    catch (IOException e)
    {
        logger.fatal("Unable to clean up db storage directory: " + e.getMessage());
        System.exit(1);
    }
}
 
源代码13 项目: dependency-track   文件: IndexManager.java
/**
 * Deletes the index directory.
 * @since 3.4.0
 */
public static void delete(final IndexType indexType) {
    final File indexDir = getIndexDirectory(indexType);
    if (indexDir.exists()) {
        LOGGER.info("Deleting " + indexType.name().toLowerCase() + " index");
        try {
            FileDeleteStrategy.FORCE.delete(indexDir);
        } catch (IOException e) {
            LOGGER.error("An error occurred deleting the " + indexType.name().toLowerCase() + " index", e);
        }
    }
}
 
 类所在包
 同包方法