All Downloads are FREE. Search and download functionalities are using the official Maven repository.

fr.insee.eno.utils.FolderCleaner Maven / Gradle / Ivy

Go to download

Eno is a tool that generates survey questionnaires starting from their formal description in DDI

There is a newer version: 2.12.1
Show newest version
package fr.insee.eno.utils;

import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * Service used to clean folders (deletes all files)
 * 
 * @author gerose
 *
 */
public class FolderCleaner {

	private final static Logger logger = LoggerFactory.getLogger(FolderCleaner.class);

	/**
	 * Generic method to clean one folder
	 * 
	 * @param folder : the folder to be cleaned
	 * @throws IOException : FileNotfound / NoAccess mainly
	 */
	public static void cleanOneFolder(File folder) throws IOException {
		logger.debug("Cleaning " + folder);
		if (folder.exists() && Files.isDirectory(folder.toPath())) {
			FileUtils.cleanDirectory(folder);
		}
		Files.deleteIfExists(Paths.get(folder.toURI()));
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy