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:io.ucoin.ucoinj.elasticsearch.Main.java

protected void initI18n(Configuration config) throws IOException {

    // --------------------------------------------------------------------//
    // init i18n//  w  w  w. ja  v  a 2  s . co m
    // --------------------------------------------------------------------//
    File i18nDirectory = new File(config.getDataDirectory(), "i18n");
    if (i18nDirectory.exists()) {
        // clean i18n cache
        FileUtils.cleanDirectory(i18nDirectory);
    }

    FileUtils.forceMkdir(i18nDirectory);

    if (log.isDebugEnabled()) {
        log.debug("I18N directory: " + i18nDirectory);
    }

    Locale i18nLocale = config.getI18nLocale();

    if (log.isInfoEnabled()) {
        log.info(String.format("Starts i18n with locale [%s] at [%s]", i18nLocale, i18nDirectory));
    }
    I18n.init(new UserI18nInitializer(i18nDirectory, new DefaultI18nInitializer(getI18nBundleName())),
            i18nLocale);
}

From source file:android.databinding.compilationTest.BaseCompilationTest.java

protected void copyResourceTo(String name, File targetFile) throws IOException {
    File directory = targetFile.getParentFile();
    FileUtils.forceMkdir(directory);
    InputStream contents = getClass().getResourceAsStream(name);
    FileOutputStream fos = new FileOutputStream(targetFile);
    IOUtils.copy(contents, fos);//  www  . j ava 2  s .  com
    IOUtils.closeQuietly(fos);
    IOUtils.closeQuietly(contents);
}

From source file:com.thoughtworks.go.plugin.infra.monitor.DefaultPluginJarLocationMonitor.java

private void validateExternalPluginDirectory() {
    if (externalPluginDirectory.exists()) {
        return;/*from  w  w  w.  java2 s .co  m*/
    }
    try {
        LOGGER.debug("Force creating the plugins jar directory as it does not exist {}",
                externalPluginDirectory.getAbsolutePath());
        FileUtils.forceMkdir(externalPluginDirectory);
    } catch (IOException e) {
        String message = "Failed to create external plugins folder in location "
                + externalPluginDirectory.getAbsolutePath();
        LOGGER.warn(message, e);
        throw new RuntimeException(message, e);
    }
}

From source file:com.norconex.committer.core.impl.FileSystemCommitter.java

private synchronized File createFile(String suffix) throws IOException {
    // Create date directory
    File dateDir = new File(directory,
            DateFormatUtils.format(System.currentTimeMillis(), "yyyy/MM-dd/hh/mm/ss"));
    if (!dateDir.exists()) {
        try {//from   w ww  .jav a 2 s .  com
            FileUtils.forceMkdir(dateDir);
        } catch (IOException e) {
            throw new CommitterException("Cannot create commit directory: " + dateDir, e);
        }
    }
    // Create file
    return new File(dateDir, TimeIdGenerator.next() + suffix);
}

From source file:context.ui.misc.FileHandler.java

/**
 *
 * @param subdirectory//  ww  w .j  av  a 2  s .c  om
 */
public static void createDirectory(String subdirectory) {
    try {
        FileUtils.forceMkdir(new File(subdirectory));
    } catch (IOException ex) {
        Exceptions.printStackTrace(ex);
    }
}

From source file:de.blizzy.backup.database.Database.java

private void copyFolder(File folder, File targetFolder, boolean zipFiles) throws IOException {
    FileUtils.forceMkdir(targetFolder);
    FileUtils.cleanDirectory(targetFolder);

    for (File file : folder.listFiles()) {
        if (file.isDirectory()) {
            copyFolder(file, new File(targetFolder, file.getName()), zipFiles);
        } else {/*  w w w .j  a v a2  s.  com*/
            if (zipFiles) {
                Utils.zipFile(file, new File(targetFolder, file.getName() + ".zip")); //$NON-NLS-1$
            } else {
                FileUtils.copyFile(file, new File(targetFolder, file.getName()));
            }
        }
    }
}

From source file:ch.entwine.weblounge.contentrepository.impl.fs.FileSystemContentRepository.java

/**
 * {@inheritDoc}/*from   w ww .  j  a va 2s  .c o  m*/
 * 
 * @see org.osgi.service.cm.ManagedService#updated(java.util.Dictionary)
 */
public void updated(Dictionary properties) throws ConfigurationException {

    // Detect the filesystem root directory
    String fsRootDir = null;
    if (StringUtils.isNotBlank(System.getProperty(PROP_ROOT_DIR)))
        fsRootDir = System.getProperty(PROP_ROOT_DIR);
    else if (properties != null && StringUtils.isNotBlank((String) properties.get(OPT_ROOT_DIR)))
        fsRootDir = (String) properties.get(OPT_ROOT_DIR);
    else
        fsRootDir = PathUtils.concat(System.getProperty("java.io.tmpdir"), ROOT_DIR_DEFAULT);

    repositoryRoot = new File(fsRootDir);
    if (site != null)
        repositorySiteRoot = new File(repositoryRoot, site.getIdentifier());
    logger.debug("Content repository storage root is located at {}", repositoryRoot);

    // Make sure we can create a temporary index
    try {
        FileUtils.forceMkdir(repositoryRoot);
    } catch (IOException e) {
        throw new ConfigurationException(OPT_ROOT_DIR,
                "Unable to create repository storage at " + repositoryRoot, e);
    }

    logger.debug("Content repository configured");
}

From source file:com.alibaba.jstorm.cluster.StormConfig.java

private static String drpc_local_dir(Map conf) throws IOException {
    String ret = String.valueOf(conf.get(Config.STORM_LOCAL_DIR)) + FILE_SEPERATEOR + "drpc";
    FileUtils.forceMkdir(new File(ret));
    return ret;//  www  .  jav  a  2s  .  c o m
}

From source file:io.druid.segment.realtime.firehose.SqlFirehoseFactoryTest.java

private File createFirehoseTmpDir(String dirSuffix) throws IOException {
    final File firehoseTempDir = File.createTempFile(SqlFirehoseFactoryTest.class.getSimpleName(), dirSuffix);
    FileUtils.forceDelete(firehoseTempDir);
    FileUtils.forceMkdir(firehoseTempDir);
    FIREHOSE_TMP_DIRS.add(firehoseTempDir);
    return firehoseTempDir;
}

From source file:de.fhg.iais.asc.oai.localwriter.RepositoryWriter.java

/**
 * next Set/*w  ww  .  j a va  2s .  co  m*/
 * 
 * @param spec
 * @return
 */
public boolean nextSetSpec(String spec) {
    if (this.idsInSet.size() > 0) {
        writeIds();
        this.idsInSet.clear();
    }
    this.sets.add(spec);
    this.currentSpec = spec;
    this.currentSpec = makeFilenameFilesystemCompatible(this.currentSpec);
    try {
        FileUtils.forceMkdir(new File(this.rootDir, this.currentSpec));
    } catch (IOException e) {
        LOG.error("", e);
    }
    this.countDown = this.maxFilesEach;
    return false;
}