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

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

Introduction

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

Prototype

public static void forceMkdir(File directory) throws IOException 

Source Link

Document

Makes a directory, including any necessary but nonexistent parent directories.

Usage

From source file:edu.cuhk.hccl.IDConverter.java

public static void main(String[] args) {
    if (args.length < 2) {
        printUsage();//w  w  w  .j a  v a  2 s .  c  o m
    }

    try {
        File inFile = new File(args[0]);
        File outFile = new File(args[1]);

        if (inFile.isDirectory()) {
            System.out.println("ID Converting begins...");
            FileUtils.forceMkdir(outFile);
            for (File file : inFile.listFiles()) {
                if (!file.isHidden())
                    processFile(file, new File(outFile.getAbsolutePath() + "/"
                            + FilenameUtils.removeExtension(file.getName()) + "-long.txt"));
            }
        } else if (inFile.isFile()) {
            System.out.println("ID Converting begins...");
            processFile(inFile, outFile);
        } else {
            printUsage();
        }

        System.out.println("ID Converting finished.");

    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:edu.kit.dama.transfer.client.util.TestDataBuilder.java

/**
 * The entry point.//from   w  ww .ja  v  a 2s. c om
 *
 * @param args Command line args.
 */
public static void main(String[] args) {
    try {
        FileUtils.forceMkdir(new File(targetDir));

        byte[] oneMegaByte = buildRandomData((int) FileUtils.ONE_KB);

        for (int i = 0; i < BASE_FILES; i++) {
            File f = new File(targetDir + i + ".bin");
            LOGGER.debug(" - Writing file {}", f);
            FileUtils.writeByteArrayToFile(f, oneMegaByte);
        }
        for (int j = 0; j < SUB_DIRS; j++) {
            String subdir = targetDir + "subDir" + j;
            for (int k = 0; k < SUB_SUB_DIRS; k++) {
                String subsubdir = subdir + "/subsubdir" + k;
                oneMegaByte = buildRandomData((int) FileUtils.ONE_KB);
                for (int i = 0; i < FILES_IN_SUB_SUB_DIRS; i++) {
                    File f = new File(subsubdir + File.separator + i + "-" + j + "-" + k + ".bin");
                    LOGGER.debug(" - Writing file {}", f);
                    FileUtils.writeByteArrayToFile(f, oneMegaByte);
                }
            }
        }
    } catch (IOException ioe) {
        LOGGER.error("Failed to build data", ioe);
    }
}

From source file:averroes.Main.java

/**
 * The main Averroes method.// ww w .j  ava 2s.  c  om
 * 
 * @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:com.btoddb.fastpersitentqueue.speedtest.SpeedTest.java

public static void main(String[] args) throws Exception {
    if (0 == args.length) {
        System.out.println();//from   w w w . ja va2 s .  co m
        System.out.println("ERROR: must specify the config file path/name");
        System.out.println();
        System.exit(1);
    }

    SpeedTestConfig config = SpeedTestConfig.create(args[0]);

    System.out.println(config.toString());

    File theDir = new File(config.getDirectory(), "speed-" + UUID.randomUUID().toString());
    FileUtils.forceMkdir(theDir);

    Fpq queue = config.getFpq();
    queue.setJournalDirectory(new File(theDir, "journals"));
    queue.setPagingDirectory(new File(theDir, "pages"));

    try {
        queue.init();

        //
        // start workers
        //

        AtomicLong counter = new AtomicLong();
        AtomicLong pushSum = new AtomicLong();
        AtomicLong popSum = new AtomicLong();

        long startTime = System.currentTimeMillis();

        Set<SpeedPushWorker> pushWorkers = new HashSet<SpeedPushWorker>();
        for (int i = 0; i < config.getNumberOfPushers(); i++) {
            pushWorkers.add(new SpeedPushWorker(queue, config, counter, pushSum));
        }

        Set<SpeedPopWorker> popWorkers = new HashSet<SpeedPopWorker>();
        for (int i = 0; i < config.getNumberOfPoppers(); i++) {
            popWorkers.add(new SpeedPopWorker(queue, config, popSum));
        }

        ExecutorService pusherExecSrvc = Executors.newFixedThreadPool(
                config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable runnable) {
                        Thread t = new Thread(runnable);
                        t.setName("SpeedTest-Pusher");
                        return t;
                    }
                });

        ExecutorService popperExecSrvc = Executors.newFixedThreadPool(
                config.getNumberOfPushers() + config.getNumberOfPoppers(), new ThreadFactory() {
                    @Override
                    public Thread newThread(Runnable runnable) {
                        Thread t = new Thread(runnable);
                        t.setName("SpeedTest-Popper");
                        return t;
                    }
                });

        long startPushing = System.currentTimeMillis();
        for (SpeedPushWorker sw : pushWorkers) {
            pusherExecSrvc.submit(sw);
        }

        long startPopping = System.currentTimeMillis();
        for (SpeedPopWorker sw : popWorkers) {
            popperExecSrvc.submit(sw);
        }

        //
        // wait to finish
        //

        long endTime = startTime + config.getDurationOfTest() * 1000;
        long endPushing = 0;
        long displayTimer = 0;
        while (0 == endPushing || !queue.isEmpty()) {
            // display status every second
            if (1000 < (System.currentTimeMillis() - displayTimer)) {
                System.out.println(String.format("status (%ds) : journals = %d : memory segments = %d",
                        (endTime - System.currentTimeMillis()) / 1000,
                        queue.getJournalMgr().getJournalIdMap().size(),
                        queue.getMemoryMgr().getSegments().size()));
                displayTimer = System.currentTimeMillis();
            }

            pusherExecSrvc.shutdown();
            if (pusherExecSrvc.awaitTermination(100, TimeUnit.MILLISECONDS)) {
                endPushing = System.currentTimeMillis();
                // tell poppers, all pushers are finished
                for (SpeedPopWorker sw : popWorkers) {
                    sw.stopWhenQueueEmpty();
                }
            }
        }

        long endPopping = System.currentTimeMillis();

        popperExecSrvc.shutdown();
        popperExecSrvc.awaitTermination(10, TimeUnit.SECONDS);

        long numberOfPushes = 0;
        for (SpeedPushWorker sw : pushWorkers) {
            numberOfPushes += sw.getNumberOfEntries();
        }

        long numberOfPops = 0;
        for (SpeedPopWorker sw : popWorkers) {
            numberOfPops += sw.getNumberOfEntries();
        }

        long pushDuration = endPushing - startPushing;
        long popDuration = endPopping - startPopping;

        System.out.println("push - pop checksum = " + pushSum.get() + " - " + popSum.get() + " = "
                + (pushSum.get() - popSum.get()));
        System.out.println("push duration = " + pushDuration);
        System.out.println("pop duration = " + popDuration);
        System.out.println();
        System.out.println("pushed = " + numberOfPushes);
        System.out.println("popped = " + numberOfPops);
        System.out.println();
        System.out.println("push entries/sec = " + numberOfPushes / (pushDuration / 1000f));
        System.out.println("pop entries/sec = " + numberOfPops / (popDuration / 1000f));
        System.out.println();
        System.out.println("journals created = " + queue.getJournalsCreated());
        System.out.println("journals removed = " + queue.getJournalsRemoved());
    } finally {
        if (null != queue) {
            queue.shutdown();
        }
        //            FileUtils.deleteDirectory(theDir);
    }
}

From source file:avantssar.aslanpp.testing.Tester.java

public static void main(String[] args) {

    Debug.initLog(LogLevel.INFO);/*from  w w w.ja  v  a2s  . c  o m*/

    TesterCommandLineOptions options = new TesterCommandLineOptions();
    try {
        options.getParser().parseArgument(args);
        options.ckeckAtEnd();
    } catch (CmdLineException ex) {
        reportException("Inconsistent options.", ex, System.err);
        options.showShortHelp(System.err);
        return;
    }

    if (options.isShowHelp()) {
        options.showLongHelp(System.out);
        return;
    }

    ASLanPPConnectorImpl translator = new ASLanPPConnectorImpl();

    if (options.isShowVersion()) {
        System.out.println(translator.getFullTitleLine());
        return;
    }

    ISpecificationBundleProvider sbp;
    File realInDir;
    if (options.isLibrary()) {
        if (options.getHornClausesLevel() != HornClausesLevel.ALL) {
            System.out.println("When checking the internal library we output all Horn clauses.");
            options.setHornClausesLevel(HornClausesLevel.ALL);
        }
        if (!options.isStripOutput()) {
            System.out.println(
                    "When checking the internal library, the ouput is stripped of comments and line information.");
            options.setStripOutput(true);
        }
        File modelsDir = new File(FilenameUtils.concat(options.getOut().getAbsolutePath(), "_models"));
        try {
            FileUtils.forceMkdir(modelsDir);
        } catch (IOException e1) {
            System.out.println("Failed to create models folder: " + e1.getMessage());
            Debug.logger.error("Failed to create models folder.", e1);
        }
        realInDir = modelsDir;
        sbp = new LibrarySpecificationsProvider(modelsDir.getAbsolutePath());
    } else {
        realInDir = options.getIn();
        sbp = new DiskSpecificationsProvider(options.getIn().getAbsolutePath());
    }

    System.setProperty(EntityManager.ASLAN_ENVVAR, sbp.getASLanPath());
    // try {
    // EntityManager.loadASLanPath();
    // }
    // catch (IOException e) {
    // System.out.println("Exception while reloading ASLANPATH: " +
    // e.getMessage());
    // Debug.logger.error("Exception while loading ASLANPATH.", e);
    // }

    try {
        bm = BackendsManager.instance();
        if (bm != null) {
            for (IBackendRunner br : bm.getBackendRunners()) {
                System.out.println(br.getFullDescription());
                if (br.getTimeout() > finalTimeout) {
                    finalTimeout = br.getTimeout();
                }
            }
        }
    } catch (IOException e) {
        System.out.println("Failed to load backends: " + e);
    }

    int threadsCount = 50;
    if (options.getThreads() > 0) {
        threadsCount = options.getThreads();
    }
    System.out.println("Will launch " + threadsCount
            + " threads in parallel (+ will show that a thread starts, - that a thread ends).");
    TranslationReport rep = new TranslationReport(
            bm != null ? bm.getBackendRunners() : new ArrayList<IBackendRunner>(), options.getOut());
    long startTime = System.currentTimeMillis();
    int specsCount = 0;
    pool = Executors.newFixedThreadPool(threadsCount);
    for (ITestTask task : sbp) {
        doTest(rep, task, realInDir, options.getOut(), translator, options, System.err);
        specsCount++;
    }
    pool.shutdown();
    String reportFile = FilenameUtils.concat(options.getOut().getAbsolutePath(), "index.html");
    try {
        while (!pool.awaitTermination(finalTimeout, TimeUnit.SECONDS)) {
        }
    } catch (InterruptedException e) {
        Debug.logger.error("Interrupted while waiting for pool termination.", e);
        System.out.println("Interrupted while waiting for pool termination: " + e.getMessage());
        System.out.println("The report may be incomplete.");
    }
    long endTime = System.currentTimeMillis();
    long duration = (endTime - startTime) / 1000;
    System.out.println();
    System.out.println(specsCount + " specifications checked in " + duration + " seconds.");
    rep.report(reportFile);
    System.out.println("You can find an overview report at '" + reportFile + "'.");
}

From source file:GIST.IzbirkomExtractor.IzbirkomExtractor.java

/**
 * @param args/*from   w ww.  j  a v  a2  s  .com*/
 */
public static void main(String[] args) {

    // process command-line options
    Options options = new Options();
    options.addOption("n", "noaddr", false, "do not do any address matching (for testing)");
    options.addOption("i", "info", false, "create and populate address information table");
    options.addOption("h", "help", false, "this message");

    // database connection
    options.addOption("s", "server", true, "database server to connect to");
    options.addOption("d", "database", true, "OSM database name");
    options.addOption("u", "user", true, "OSM database user name");
    options.addOption("p", "pass", true, "OSM database password");

    // logging options
    options.addOption("l", "logdir", true, "log file directory (default './logs')");
    options.addOption("e", "loglevel", true, "log level (default 'FINEST')");

    // automatically generate the help statement
    HelpFormatter help_formatter = new HelpFormatter();

    // database URI for connection
    String dburi = null;

    // Information message for help screen
    String info_msg = "IzbirkomExtractor [options] <html_directory>";

    try {
        CommandLineParser parser = new GnuParser();
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption('h') || cmd.getArgs().length != 1) {
            help_formatter.printHelp(info_msg, options);
            System.exit(1);
        }

        /* prohibit n and i together */
        if (cmd.hasOption('n') && cmd.hasOption('i')) {
            System.err.println("Options 'n' and 'i' cannot be used together.");
            System.exit(1);
        }

        /* require database arguments without -n */
        if (cmd.hasOption('n')
                && (cmd.hasOption('s') || cmd.hasOption('d') || cmd.hasOption('u') || cmd.hasOption('p'))) {
            System.err.println("Options 'n' and does not need any databse parameters.");
            System.exit(1);
        }

        /* require all 4 database options to be used together */
        if (!cmd.hasOption('n')
                && !(cmd.hasOption('s') && cmd.hasOption('d') && cmd.hasOption('u') && cmd.hasOption('p'))) {
            System.err.println(
                    "For database access all of the following arguments have to be specified: server, database, user, pass");
            System.exit(1);
        }

        /* useful variables */
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd'T'kk:mm");
        String dateString = formatter.format(new Date());

        /* setup logging */
        File logdir = new File(cmd.hasOption('l') ? cmd.getOptionValue('l') : "logs");
        FileUtils.forceMkdir(logdir);
        File log_file_name = new File(
                logdir + "/" + IzbirkomExtractor.class.getName() + "-" + formatter.format(new Date()) + ".log");
        FileHandler log_file = new FileHandler(log_file_name.getPath());

        /* create "latest" link to currently created log file */
        Path latest_log_link = Paths.get(logdir + "/latest");
        Files.deleteIfExists(latest_log_link);
        Files.createSymbolicLink(latest_log_link, Paths.get(log_file_name.getName()));

        log_file.setFormatter(new SimpleFormatter());
        LogManager.getLogManager().reset(); // prevents logging to console
        logger.addHandler(log_file);
        logger.setLevel(cmd.hasOption('e') ? Level.parse(cmd.getOptionValue('e')) : Level.FINEST);

        // open directory with HTML files and create file list
        File dir = new File(cmd.getArgs()[0]);
        if (!dir.isDirectory()) {
            System.err.println("Unable to find directory '" + cmd.getArgs()[0] + "', exiting");
            System.exit(1);
        }
        PathMatcher pmatcher = FileSystems.getDefault()
                .getPathMatcher("glob:?  * ?*.html");
        ArrayList<File> html_files = new ArrayList<>();
        for (Path file : Files.newDirectoryStream(dir.toPath()))
            if (pmatcher.matches(file.getFileName()))
                html_files.add(file.toFile());
        if (html_files.size() == 0) {
            System.err.println("No matching HTML files found in '" + dir.getAbsolutePath() + "', exiting");
            System.exit(1);
        }

        // create csvResultSink
        FileOutputStream csvout_file = new FileOutputStream("parsed_addresses-" + dateString + ".csv");
        OutputStreamWriter csvout = new OutputStreamWriter(csvout_file, "UTF-8");
        ResultSink csvResultSink = new CSVResultSink(csvout, new CSVStrategy('|', '"', '#'));

        // Connect to DB and osmAddressMatcher
        AddressMatcher osmAddressMatcher;
        DBSink dbSink = null;
        DBInfoSink dbInfoSink = null;
        if (cmd.hasOption('n')) {
            osmAddressMatcher = new DummyAddressMatcher();
        } else {
            dburi = "jdbc:postgresql://" + cmd.getOptionValue('s') + "/" + cmd.getOptionValue('d');
            Connection con = DriverManager.getConnection(dburi, cmd.getOptionValue('u'),
                    cmd.getOptionValue('p'));
            osmAddressMatcher = new OsmAddressMatcher(con);
            dbSink = new DBSink(con);
            if (cmd.hasOption('i'))
                dbInfoSink = new DBInfoSink(con);
        }

        /* create resultsinks */
        SinkMultiplexor sm = SinkMultiplexor.newSinkMultiplexor();
        sm.addResultSink(csvResultSink);
        if (dbSink != null) {
            sm.addResultSink(dbSink);
            if (dbInfoSink != null)
                sm.addResultSink(dbInfoSink);
        }

        // create tableExtractor
        TableExtractor te = new TableExtractor(osmAddressMatcher, sm);

        // TODO: printout summary of options: processing date/time, host, directory of HTML files, jdbc uri, command line with parameters

        // iterate through files
        logger.info("Start processing " + html_files.size() + " files in " + dir);
        for (int i = 0; i < html_files.size(); i++) {
            System.err.println("Parsing #" + i + ": " + html_files.get(i));
            te.processHTMLfile(html_files.get(i));
        }

        System.err.println("Processed " + html_files.size() + " HTML files");
        logger.info("Finished processing " + html_files.size() + " files in " + dir);

    } catch (ParseException e1) {
        System.err.println("Failed to parse CLI: " + e1.getMessage());
        help_formatter.printHelp(info_msg, options);
        System.exit(1);
    } catch (IOException e) {
        System.err.println("I/O Exception: " + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    } catch (SQLException e) {
        System.err.println("Database '" + dburi + "': " + e.getMessage());
        System.exit(1);
    } catch (ResultSinkException e) {
        System.err.println("Failed to initialize ResultSink: " + e.getMessage());
        System.exit(1);
    } catch (TableExtractorException e) {
        System.err.println("Failed to initialize Table Extractor: " + e.getMessage());
        System.exit(1);
    } catch (CloneNotSupportedException | IllegalAccessException | InstantiationException e) {
        System.err.println("Something really odd happened: " + e.getMessage());
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:com.handany.base.generator.Generator.java

public static void main(String[] args) throws IOException {
    String directoryPath = "src/main/java";

    String modelDirectory = directoryPath + File.separator
            + StringUtils.replace(MODEL_PACKAGE, ".", File.separator) + File.separator;
    String daoDirectory = directoryPath + File.separator + StringUtils.replace(DAO_PACKAGE, ".", File.separator)
            + File.separator;//from  ww  w .j a  va2  s  .c o m
    String serviceDirectory = directoryPath + File.separator
            + StringUtils.replace(SERVICE_PACKAGE, ".", File.separator) + File.separator;
    String serviceImplDirectory = directoryPath + File.separator
            + StringUtils.replace(SERVICE_IMPL_PACKAGE, ".", File.separator) + File.separator;
    String controllerDirectory = directoryPath + File.separator
            + StringUtils.replace(CONTROLLER_PACKAGE, ".", File.separator) + File.separator;
    File fileDirectory = new File(directoryPath);
    if (!fileDirectory.isDirectory()) {
        FileUtils.forceMkdir(fileDirectory);
    }

    List<TableBean> tableBeanList = getTables();

    ArrayList<String> nameList = new ArrayList<>();

    //      nameList.add("bm_classroom_course");
    nameList.add("bm_sales_promotion");

    for (TableBean tableBean : tableBeanList) {
        System.out.println("table:" + tableBean.getTableName());
        String tableName = tableBean.getTableName();

        if (!nameList.contains(tableName.toLowerCase())) {
            continue;
        }

        Map<String, Object> varMap = new HashMap<>();
        varMap.put("tableBean", tableBean);
        varMap.put("schemaName", SCHEMA_NAME);
        varMap.put("modelPackage", MODEL_PACKAGE);
        varMap.put("daoPackage", DAO_PACKAGE);
        varMap.put("servicePackage", SERVICE_PACKAGE);
        varMap.put("serviceImplPackage", SERVICE_IMPL_PACKAGE);
        varMap.put("controllerPackage", CONTROLLER_PACKAGE);

        Template modelTemplate = FreemarkerUtil.getTemplate("model.ftl");
        FreemarkerUtil.outputProcessResult(modelDirectory + tableBean.getTableNameCapitalized() + ".java",
                modelTemplate, varMap);

        //            Template daoTemplate = FreemarkerUtil.getTemplate("dao.ftl");
        //            FreemarkerUtil.outputProcessResult(daoDirectory + tableBean.getTableNameCapitalized() + "Mapper.java", daoTemplate, varMap);

        Template mapperTemplate = FreemarkerUtil.getTemplate("mapper.ftl");
        FreemarkerUtil.outputProcessResult(daoDirectory + tableBean.getTableNameCapitalized() + "Mapper.xml",
                mapperTemplate, varMap);

        //            Template serviceTemplate = FreemarkerUtil.getTemplate("service.ftl");
        //            FreemarkerUtil.outputProcessResult(serviceDirectory + tableBean.getTableNameCapitalized() + "Service.java", serviceTemplate, varMap);
        //
        //            Template serviceImplTemplate = FreemarkerUtil.getTemplate("serviceimpl.ftl");
        //            FreemarkerUtil.outputProcessResult(serviceImplDirectory + tableBean.getTableNameCapitalized() + "ServiceImpl.java", serviceImplTemplate, varMap);
        //
        //            Template controllerTemplate = FreemarkerUtil.getTemplate("controller.ftl");
        //            FreemarkerUtil.outputProcessResult(controllerDirectory + tableBean.getTableNameCapitalized() + "Controller.java", controllerTemplate, varMap);
    }
}

From source file:com.hp.autonomy.idolutils.GenerateIndexableXmlDocumentTest.java

@BeforeClass
public static void init() throws IOException {
    FileUtils.forceMkdir(TEST_DIR);
}

From source file:com.googlecode.fightinglayoutbugs.helpers.FileHelper.java

public static void createParentDirectoryIfNeeded(@Nonnull File file) {
    final File dir = checkNotNull(file, "Method parameter file must not be null.").getParentFile();
    try {/*from w  ww.j av a 2  s .c o m*/
        if (dir != null && !dir.exists()) {
            FileUtils.forceMkdir(dir);
        }
    } catch (IOException e) {
        throw new RuntimeException("Failed to create directory: " + dir, e);
    }
}

From source file:com.vmware.demo.sgf.lucene.LuceneIndexBuilder.java

/**
 * Create the index directory also remove the write.lock file if it exists.
 * /*from  w  w w  . j  av a2  s  . c  om*/
 * @throws IOException
 */
private static String createIndexDirectory(final String indexDirectory) throws IOException {
    String dirPath = indexDirectory + "-" + UUID.randomUUID();
    FileUtils.forceMkdir(new File(dirPath));
    FileUtils.deleteQuietly(new File(dirPath + "/write.lock"));
    return dirPath;
}