Example usage for org.apache.commons.io FileUtils cleanDirectory

List of usage examples for org.apache.commons.io FileUtils cleanDirectory

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils cleanDirectory.

Prototype

public static void cleanDirectory(File directory) throws IOException 

Source Link

Document

Cleans a directory without deleting it.

Usage

From source file:averroes.Main.java

/**
 * The main Averroes method.//from  w w  w  .j ava 2s.com
 * 
 * @param args
 */
public static void main(String[] args) {
    try {
        // Find the total execution time, instead of depending on the Unix
        // time command
        TimeUtils.splitStart();

        // Process the arguments
        AverroesOptions.processArguments(args);

        // Reset Soot
        G.reset();

        // Create the output directory and clean up any class files in there
        FileUtils.forceMkdir(Paths.libraryClassesOutputDirectory());
        FileUtils.cleanDirectory(Paths.classesOutputDirectory());

        // Organize the input JAR files
        System.out.println("");
        System.out.println("Organizing the JAR files ...");
        JarOrganizer jarOrganizer = new JarOrganizer();
        jarOrganizer.organizeInputJarFiles();

        // Print some statistics
        System.out.println("# application classes: " + jarOrganizer.applicationClassNames().size());
        System.out.println("# library classes: " + jarOrganizer.libraryClassNames().size());

        // Add the organized archives for the application and its
        // dependencies.
        TimeUtils.reset();
        JarFactoryClassProvider provider = new JarFactoryClassProvider();
        provider.prepareJarFactoryClasspath();

        // Set some soot parameters
        SourceLocator.v().setClassProviders(Collections.singletonList((ClassProvider) provider));
        SootSceneUtil.addCommonDynamicClasses(provider);
        Options.v().classes().addAll(provider.getApplicationClassNames());
        Options.v().set_main_class(AverroesOptions.getMainClass());
        Options.v().set_validate(true);

        // Load the necessary classes
        System.out.println("");
        System.out.println("Loading classes ...");
        Scene.v().loadNecessaryClasses();
        Scene.v().setMainClassFromOptions();
        double soot = TimeUtils.elapsedTime();
        System.out.println("Soot loaded the input classes in " + soot + " seconds.");

        // Now let Averroes do its thing
        // First, create the class hierarchy
        TimeUtils.reset();
        System.out.println("");
        System.out.println("Creating the class hierarchy for the placeholder library ...");
        Hierarchy.v();

        // Output some initial statistics
        System.out.println("# initial application classes: " + Hierarchy.v().getApplicationClasses().size());
        System.out.println("# initial library classes: " + Hierarchy.v().getLibraryClasses().size());
        System.out.println("# initial library methods: " + Hierarchy.v().getLibraryMethodCount());
        System.out.println("# initial library fields: " + Hierarchy.v().getLibraryFieldCount());
        System.out.println("# referenced library methods: " + Hierarchy.v().getReferencedLibraryMethodCount());
        System.out.println("# referenced library fields: " + Hierarchy.v().getReferencedLibraryFieldCount());

        // Cleanup the hierarchy
        System.out.println("");
        System.out.println("Cleaning up the class hierarchy ...");
        Hierarchy.v().cleanupLibraryClasses();

        // Output some cleanup statistics
        System.out.println("# removed library methods: " + Hierarchy.v().getRemovedLibraryMethodCount());
        System.out.println("# removed library fields: " + Hierarchy.v().getRemovedLibraryFieldCount());
        // The +1 is for Finalizer.register that will be added later
        System.out.println("# final library methods: " + (Hierarchy.v().getLibraryMethodCount() + 1));
        System.out.println("# final library fields: " + Hierarchy.v().getLibraryFieldCount());

        // Output some code generation statistics
        System.out.println("");
        System.out.println("Generating extra library classes ...");
        System.out.println("# generated library classes: " + CodeGenerator.v().getGeneratedClassCount());
        System.out.println("# generated library methods: " + CodeGenerator.v().getGeneratedMethodCount());

        // Create the Averroes library class
        System.out.println("");
        System.out.println("Creating the skeleton for Averroes's main library class ...");
        CodeGenerator.v().createAverroesLibraryClass();

        // Create method bodies to the library classes
        System.out.println("Generating the method bodies for the placeholder library classes ...");
        CodeGenerator.v().createLibraryMethodBodies();

        // Create empty classes for the basic classes required internally by
        // Soot
        System.out.println("Generating empty basic library classes required by Soot ...");
        for (SootClass basicClass : Hierarchy.v().getBasicClassesDatabase().getMissingBasicClasses()) {
            CodeGenerator.writeLibraryClassFile(basicClass);
        }
        double averroes = TimeUtils.elapsedTime();
        System.out.println("Placeholder library classes created and validated in " + averroes + " seconds.");

        // Create the jar file and add all the generated class files to it.
        TimeUtils.reset();
        JarFile librJarFile = new JarFile(Paths.placeholderLibraryJarFile());
        librJarFile.addGeneratedLibraryClassFiles();
        JarFile aveJarFile = new JarFile(Paths.averroesLibraryClassJarFile());
        aveJarFile.addAverroesLibraryClassFile();
        double bcel = TimeUtils.elapsedTime();
        System.out.println("Placeholder library JAR file verified in " + bcel + " seconds.");
        System.out.println(
                "Total time (without verification) is " + MathUtils.round(soot + averroes) + " seconds.");
        System.out.println(
                "Total time (with verification) is " + MathUtils.round(soot + averroes + bcel) + " seconds.");

        double total = TimeUtils.elapsedSplitTime();
        System.out.println("Elapsed time: " + total + " seconds.");
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:it.anyplace.sync.webclient.Main.java

public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("C", "set-config", true, "set config file for s-client");
    options.addOption("h", "help", false, "print help");
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("s-client", options);
        return;/* w  w w  .j a v a 2s . c om*/
    }

    File configFile = cmd.hasOption("C") ? new File(cmd.getOptionValue("C"))
            : new File(System.getProperty("user.home"), ".s-client.properties");
    logger.info("using config file = {}", configFile);
    try (ConfigurationService configuration = ConfigurationService.newLoader().loadFrom(configFile)) {
        FileUtils.cleanDirectory(configuration.getTemp());
        KeystoreHandler.newLoader().loadAndStore(configuration);
        logger.debug("{}", configuration.getStorageInfo().dumpAvailableSpace());
        try (HttpService httpService = new HttpService(configuration)) {
            httpService.start();
            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(
                        URI.create("http://localhost:" + httpService.getPort() + "/web/webclient.html"));
            }
            httpService.join();
        }
    }
}

From source file:compressor.Compressor.java

/**
 * @param args the command line arguments
 *
 * args[0] is the file path including the filename
 *
 *
 * args[1] is the base folder//from   w w w .  j a  v  a  2 s .  c  o  m
 *
 *
 * args[2] is the path to the pdf
 * @throws java.io.IOException
 * @throws java.io.FileNotFoundException
 * @throws org.apache.pdfbox.exceptions.COSVisitorException
 */
public static void main(String[] args) throws IOException, FileNotFoundException, COSVisitorException {

    if (args[0] != null && args[1] != null && args[2] != null) {

        Compressor cp = new Compressor();

        String src = args[0];

        try {

            String image_name = FilenameUtils.getBaseName(args[0]);

            // @param1 is the full filepath
            // @param2 is the base folder which is the e.g. /home/mxp/Pictures/
            // @param3 is the naked image name without extension
            cp.extract_images(src, args[1], image_name);

            // @param1 is the src extracted path
            // @param2 is the compressed path
            cp.compress_images(args[1] + "img/", args[1]);

        } catch (Exception e) {

        } finally {

            FileUtils.cleanDirectory(new File(args[1] + "img/"));
            FileUtils.cleanDirectory(new File(args[1] + "compressed/"));
        }

    } else {

        System.out.println("parameters are missing");
    }

}

From source file:it.anyplace.sync.client.Main.java

public static void main(String[] args) throws Exception {
    Options options = new Options();
    options.addOption("C", "set-config", true, "set config file for s-client");
    options.addOption("c", "config", false, "dump config");
    options.addOption("sp", "set-peers", true, "set peer, or comma-separated list of peers");
    options.addOption("q", "query", true, "query directory server for device id");
    options.addOption("d", "discovery", true, "discovery local network for device id");
    options.addOption("p", "pull", true, "pull file from network");
    options.addOption("P", "push", true, "push file to network");
    options.addOption("o", "output", true, "set output file/directory");
    options.addOption("i", "input", true, "set input file/directory");
    options.addOption("lp", "list-peers", false, "list peer addresses");
    options.addOption("a", "address", true, "use this peer addresses");
    options.addOption("L", "list-remote", false, "list folder (root) content from network");
    options.addOption("I", "list-info", false, "dump folder info from network");
    options.addOption("li", "list-info", false, "list folder info from local db");
    //        options.addOption("l", "list-local", false, "list folder content from local (saved) index");
    options.addOption("s", "search", true, "search local index for <term>");
    options.addOption("D", "delete", true, "push delete to network");
    options.addOption("M", "mkdir", true, "push directory create to network");
    options.addOption("h", "help", false, "print help");
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);

    if (cmd.hasOption("h")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("s-client", options);
        return;/*w w w  . j  a  v  a2s . co m*/
    }

    File configFile = cmd.hasOption("C") ? new File(cmd.getOptionValue("C"))
            : new File(System.getProperty("user.home"), ".s-client.properties");
    logger.info("using config file = {}", configFile);
    ConfigurationService configuration = ConfigurationService.newLoader().loadFrom(configFile);
    FileUtils.cleanDirectory(configuration.getTemp());
    KeystoreHandler.newLoader().loadAndStore(configuration);
    if (cmd.hasOption("c")) {
        logger.info("configuration =\n{}", configuration.newWriter().dumpToString());
    } else {
        logger.trace("configuration =\n{}", configuration.newWriter().dumpToString());
    }
    logger.debug("{}", configuration.getStorageInfo().dumpAvailableSpace());

    if (cmd.hasOption("sp")) {
        List<String> peers = Lists.newArrayList(Lists.transform(
                Arrays.<String>asList(cmd.getOptionValue("sp").split(",")), new Function<String, String>() {
                    @Override
                    public String apply(String input) {
                        return input.trim();
                    }
                }));
        logger.info("set peers = {}", peers);
        configuration.edit().setPeers(Collections.<DeviceInfo>emptyList());
        for (String peer : peers) {
            KeystoreHandler.validateDeviceId(peer);
            configuration.edit().addPeers(new DeviceInfo(peer, null));
        }
        configuration.edit().persistNow();
    }

    if (cmd.hasOption("q")) {
        String deviceId = cmd.getOptionValue("q");
        logger.info("query device id = {}", deviceId);
        List<DeviceAddress> deviceAddresses = new GlobalDiscoveryHandler(configuration).query(deviceId);
        logger.info("server response = {}", deviceAddresses);
    }
    if (cmd.hasOption("d")) {
        String deviceId = cmd.getOptionValue("d");
        logger.info("discovery device id = {}", deviceId);
        List<DeviceAddress> deviceAddresses = new LocalDiscorveryHandler(configuration).queryAndClose(deviceId);
        logger.info("local response = {}", deviceAddresses);
    }

    if (cmd.hasOption("p")) {
        String path = cmd.getOptionValue("p");
        logger.info("file path = {}", path);
        String folder = path.split(":")[0];
        path = path.split(":")[1];
        try (SyncthingClient client = new SyncthingClient(configuration);
                BlockExchangeConnectionHandler connectionHandler = client.connectToBestPeer()) {
            InputStream inputStream = client.pullFile(connectionHandler, folder, path).waitForComplete()
                    .getInputStream();
            String fileName = client.getIndexHandler().getFileInfoByPath(folder, path).getFileName();
            File file;
            if (cmd.hasOption("o")) {
                File param = new File(cmd.getOptionValue("o"));
                file = param.isDirectory() ? new File(param, fileName) : param;
            } else {
                file = new File(fileName);
            }
            FileUtils.copyInputStreamToFile(inputStream, file);
            logger.info("saved file to = {}", file.getAbsolutePath());
        }
    }
    if (cmd.hasOption("P")) {
        String path = cmd.getOptionValue("P");
        File file = new File(cmd.getOptionValue("i"));
        checkArgument(!path.startsWith("/")); //TODO check path syntax
        logger.info("file path = {}", path);
        String folder = path.split(":")[0];
        path = path.split(":")[1];
        try (SyncthingClient client = new SyncthingClient(configuration);
                BlockPusher.FileUploadObserver fileUploadObserver = client.pushFile(new FileInputStream(file),
                        folder, path)) {
            while (!fileUploadObserver.isCompleted()) {
                fileUploadObserver.waitForProgressUpdate();
                logger.debug("upload progress {}", fileUploadObserver.getProgressMessage());
            }
            logger.info("uploaded file to network");
        }
    }
    if (cmd.hasOption("D")) {
        String path = cmd.getOptionValue("D");
        String folder = path.split(":")[0];
        path = path.split(":")[1];
        logger.info("delete path = {}", path);
        try (SyncthingClient client = new SyncthingClient(configuration);
                IndexEditObserver observer = client.pushDelete(folder, path)) {
            observer.waitForComplete();
            logger.info("deleted path");
        }
    }
    if (cmd.hasOption("M")) {
        String path = cmd.getOptionValue("M");
        String folder = path.split(":")[0];
        path = path.split(":")[1];
        logger.info("dir path = {}", path);
        try (SyncthingClient client = new SyncthingClient(configuration);
                IndexEditObserver observer = client.pushDir(folder, path)) {
            observer.waitForComplete();
            logger.info("uploaded dir to network");
        }
    }
    if (cmd.hasOption("L")) {
        try (SyncthingClient client = new SyncthingClient(configuration)) {
            client.waitForRemoteIndexAquired();
            for (String folder : client.getIndexHandler().getFolderList()) {
                try (IndexBrowser indexBrowser = client.getIndexHandler().newIndexBrowserBuilder()
                        .setFolder(folder).build()) {
                    logger.info("list folder = {}", indexBrowser.getFolder());
                    for (FileInfo fileInfo : indexBrowser.listFiles()) {
                        logger.info("\t\t{} {} {}", fileInfo.getType().name().substring(0, 1),
                                fileInfo.getPath(), fileInfo.describeSize());
                    }
                }
            }
        }
    }
    if (cmd.hasOption("I")) {
        try (SyncthingClient client = new SyncthingClient(configuration)) {
            if (cmd.hasOption("a")) {
                String deviceId = cmd.getOptionValue("a").substring(0, 63),
                        address = cmd.getOptionValue("a").substring(64);
                try (BlockExchangeConnectionHandler connection = client.getConnection(
                        DeviceAddress.newBuilder().setDeviceId(deviceId).setAddress(address).build())) {
                    client.getIndexHandler().waitForRemoteIndexAquired(connection);
                }
            } else {
                client.waitForRemoteIndexAquired();
            }
            String folderInfo = "";
            for (String folder : client.getIndexHandler().getFolderList()) {
                folderInfo += "\n\t\tfolder info : " + client.getIndexHandler().getFolderInfo(folder);
                folderInfo += "\n\t\tfolder stats : "
                        + client.getIndexHandler().newFolderBrowser().getFolderStats(folder).dumpInfo() + "\n";
            }
            logger.info("folders:\n{}\n", folderInfo);
        }
    }
    if (cmd.hasOption("li")) {
        try (SyncthingClient client = new SyncthingClient(configuration)) {
            String folderInfo = "";
            for (String folder : client.getIndexHandler().getFolderList()) {
                folderInfo += "\n\t\tfolder info : " + client.getIndexHandler().getFolderInfo(folder);
                folderInfo += "\n\t\tfolder stats : "
                        + client.getIndexHandler().newFolderBrowser().getFolderStats(folder).dumpInfo() + "\n";
            }
            logger.info("folders:\n{}\n", folderInfo);
        }
    }
    if (cmd.hasOption("lp")) {
        try (SyncthingClient client = new SyncthingClient(configuration);
                DeviceAddressSupplier deviceAddressSupplier = client.getDiscoveryHandler()
                        .newDeviceAddressSupplier()) {
            String deviceAddressesStr = "";
            for (DeviceAddress deviceAddress : Lists.newArrayList(deviceAddressSupplier)) {
                deviceAddressesStr += "\n\t\t" + deviceAddress.getDeviceId() + " : "
                        + deviceAddress.getAddress();
            }
            logger.info("device addresses:\n{}\n", deviceAddressesStr);
        }
    }
    if (cmd.hasOption("s")) {
        String term = cmd.getOptionValue("s");
        try (SyncthingClient client = new SyncthingClient(configuration);
                IndexFinder indexFinder = client.getIndexHandler().newIndexFinderBuilder().build()) {
            client.waitForRemoteIndexAquired();
            logger.info("search term = '{}'", term);
            IndexFinder.SearchCompletedEvent event = indexFinder.doSearch(term);
            if (event.hasGoodResults()) {
                logger.info("search results for term = '{}' :", term);
                for (FileInfo fileInfo : event.getResultList()) {
                    logger.info("\t\t{} {} {}", fileInfo.getType().name().substring(0, 1), fileInfo.getPath(),
                            fileInfo.describeSize());
                }
            } else if (event.hasTooManyResults()) {
                logger.info("too many results found for term = '{}'", term);
            } else {
                logger.info("no result found for term = '{}'", term);
            }
        }
    }
    //        if (cmd.hasOption("l")) {
    //            String indexDump = new IndexHandler(configuration).dumpIndex();
    //            logger.info("index dump = \n\n{}\n", indexDump);
    //        }
    IOUtils.closeQuietly(configuration);
}

From source file:it.isislab.dmason.util.SystemManagement.Worker.thrower.DMasonWorker.java

public static void main(String[] args) {
    RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();

    ///*  w w w.  j  ava 2s  . c  o m*/
    // Get name representing the running Java virtual machine.
    // It returns something like 6460@AURORA. Where the value
    // before the @ symbol is the PID.
    //
    String jvmName = bean.getName();

    //Used for log4j properties
    System.setProperty("logfile.name", "worker" + jvmName);

    //Used for log4j properties
    System.setProperty("steplog.name", "workerStep" + jvmName);

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss_SS");
    Date date = new Date();
    dateFormat.format(date);

    System.setProperty("timestamp", date.toLocaleString());

    System.setProperty("paramsfile.name", "params");
    try {
        File logPath = new File("Logs/workers");
        if (logPath.exists())
            FileUtils.cleanDirectory(logPath);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    logger = Logger.getLogger(DMasonWorker.class.getCanonicalName());
    logger.debug("StartWorker " + version);

    autoStart = false;
    connect = false;
    ip = null;
    port = null;
    String topic = "";
    updated = false;
    isBatch = false;
    topicPrefix = "";

    if (args.length == 0) {
        // Force waiting for beacon (requires ActiveMQWrapper)
        autoStart = false;
        connect = true;
    } else if (args.length == 2) {
        // Launched with IP and Port
        ip = args[0];
        port = args[1];
        autoStart = true;
        connect = true;
    } else if (args.length == 4) {
        // Used by D-Mason in order to restart a 
        // worker after update, batch execution, reset
        autoStart = true;
        ip = args[0];
        port = args[1];
        topic = args[2];
        if (args[3].equals("update")) {
            updated = true;
        }
        if (args[3].equals("reset")) {
            updated = false;
            isBatch = false;
        }
        if (args[3].contains("Batch")) {
            updated = false;
            isBatch = true;
            topicPrefix = args[3];
        }
    } else {
        System.out.println("Usage: StartWorker IP PORT");
    }

    DMasonWorker worker = new DMasonWorker(ip, port, topic);

    boolean connected = worker.startConnection();

    if (connected) {
        logger.debug("CONNECTED:");
        logger.debug("   IP     : " + worker.ipAddress.getIPaddress());
        logger.debug("   Port   : " + worker.ipAddress.getPort());
        logger.debug("   Prefix : " + DMasonWorker.topicPrefix);
        logger.debug("   Topic  : " + worker.myTopic);
    } else {
        logger.info("CONNECTION FAILED:");
        logger.debug("   IP     : " + worker.ipAddress.getIPaddress());
        logger.debug("   Port   : " + worker.ipAddress.getPort());
        logger.debug("   Prefix : " + DMasonWorker.topicPrefix);
        logger.debug("   Topic  : " + worker.myTopic);
    }
}

From source file:it.isislab.dmason.util.SystemManagement.Worker.thrower.DMasonWorkerWithGui.java

public static void main(String[] args) {
    RuntimeMXBean bean = ManagementFactory.getRuntimeMXBean();

    ///*www .j a  v  a 2 s .c  om*/
    // Get name representing the running Java virtual machine.
    // It returns something like 6460@AURORA. Where the value
    // before the @ symbol is the PID.
    //
    String jvmName = bean.getName();

    //Used for log4j properties
    System.setProperty("logfile.name", "worker" + jvmName);

    //Used for log4j properties
    System.setProperty("steplog.name", "workerStep" + jvmName);

    DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd_HH_mm_ss_SS");
    Date date = new Date();
    dateFormat.format(date);

    System.setProperty("timestamp", date.toLocaleString());

    System.setProperty("paramsfile.name", "params");
    try {
        File logPath = new File("Logs/workers");
        if (logPath.exists())
            FileUtils.cleanDirectory(logPath);
    } catch (IOException e) {
        //not a problem
    }

    logger = Logger.getLogger(DMasonWorker.class.getCanonicalName());
    logger.debug("StartWorker " + VERSION);

    autoStart = false;

    String ip = null;
    String port = null;
    String topic = "";
    updated = false;
    isBatch = false;
    topicPrefix = "";

    // ip, post, autoconnect
    if (args.length == 3) {
        ip = args[0];
        port = args[1];
        if (args[2].equals("autoconnect")) {
            autoStart = true;
        }
    }
    // ip, post, topic, event 
    if (args.length == 4) {
        autoStart = true;
        if (args[3].equals("update")) {
            updated = true;
        }
        if (args[3].equals("reset")) {
            updated = false;
            isBatch = false;
        }
        if (args[3].contains("Batch")) {
            updated = false;
            isBatch = true;
            topicPrefix = args[3];
        }
        ip = args[0];
        port = args[1];
        topic = args[2];
    }

    /*if(args.length == 2 && args[0].equals("auto"))
    {   autoStart = true;
       updated = true;
       topic = args[1];
    }
    if(args.length == 1 && args[0].equals("auto"))
    {   autoStart = true;
    }*/
    new DMasonWorkerWithGui(autoStart, updated, isBatch, topic, ip, port);
}

From source file:edu.southampton.wais.crowd.terrier.applications.Indexing.java

/** 
 * Used for testing purposes.//  ww w.ja v a2  s  .  c om
 * @param args the command line arguments.
 */
public static void main(String[] args) {
    long startTime = System.currentTimeMillis();

    Indexing t = new Indexing();

    t.setTRECIndexing(t.terrierIndexPath, t.terrierIndexPrefix);

    logger.info("Cleaning the dirs with previous index..");

    try {

        FileUtils.cleanDirectory(new File(t.terrierIndexPath));

    } catch (IOException e) {
        // TODO Auto-generated catch block

        e.printStackTrace();

        logger.info("Exception : " + e.getMessage());

    }

    logger.info("Cleaning done");

    t.index();

    long endTime = System.currentTimeMillis();

    if (logger.isInfoEnabled())

        logger.info("Elapsed time=" + ((endTime - startTime) / 1000.0D));

}

From source file:io.logspace.system.SystemTestUtils.java

public static void prepareDemoDirectory() {
    try {/*from www . j a va2  s  .  co m*/
        File directory = new File(System.getProperty("java.io.tmpdir"), "logspace-demo");
        directory.mkdirs();
        FileUtils.cleanDirectory(directory);
    } catch (IOException e) {
        // do nothing (cleanDirectory may fail on Windows systems because the directory could be in use by an old process)
    }
}

From source file:eu.planets_project.services.utils.ZipUtilsTest.java

/**
 * @throws java.lang.Exception//  w  w  w  . j a va2 s  .  co m
 */
@BeforeClass
public static void setUpBeforeClass() throws Exception {
    outputFolder = new File(DigitalObjectUtils.SYSTEM_TEMP_DIR, "ZipUtils_Test_Tmp".toUpperCase());
    FileUtils.forceMkdir(outputFolder);
    extractResultOut = new File(outputFolder, "EXTRACTED");
    FileUtils.forceMkdir(extractResultOut);
    FileUtils.cleanDirectory(outputFolder);
    zip = ZipUtils.createZip(TEST_FILE_FOLDER, outputFolder, TEST_FILE_FOLDER.getName() + ".zip", false);
}

From source file:es.urjc.mctwp.bbeans.research.SessionUtils.java

public static void cleanFolder(File folder) {

    if ((folder != null) && (folder.isDirectory())) {
        try {/*from   w  ww. jav  a 2s.c  om*/
            FileUtils.cleanDirectory(folder);
        } catch (IOException ioe) {
            logger.error("Could not clean user temp directory");
            //throw ioe;
        }
    }
}