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:it.geosolutions.geostore.services.rest.auditing.AuditingTestsUtils.java

static void createDirectory(File directory) {
    try {//from   ww  w  . j a  v  a2s.  c  o m
        FileUtils.forceMkdir(directory);
    } catch (Exception exception) {
        throw new AuditingException(exception, "Error creating directory '%s'.", directory.getAbsolutePath());
    }
}

From source file:azkaban.app.AzkabanApplicationTest.java

private File mktempdir(String name) throws IOException {
    File dir = File.createTempFile(name, ".d");
    FileUtils.forceDelete(dir);/*  w  ww .j av  a  2  s . c om*/
    FileUtils.forceMkdir(dir);
    return dir;
}

From source file:com.linkedin.pinot.controller.api.resources.FileUploadPathProvider.java

public FileUploadPathProvider(ControllerConf controllerConf) throws InvalidControllerConfigException {
    _controllerConf = controllerConf;//from ww w . j  a  va  2 s . c o  m
    try {
        _baseDataDir = new File(_controllerConf.getDataDir());
        if (!_baseDataDir.exists()) {
            FileUtils.forceMkdir(_baseDataDir);
        }
        _fileUploadTmpDir = new File(_baseDataDir, "fileUploadTemp");
        if (!_fileUploadTmpDir.exists()) {
            FileUtils.forceMkdir(_fileUploadTmpDir);
        }
        _tmpUntarredPath = new File(_fileUploadTmpDir, "untarred");
        if (!_tmpUntarredPath.exists()) {
            _tmpUntarredPath.mkdirs();
        }
        _schemasTmpDir = new File(_baseDataDir, "schemasTemp");
        if (!_schemasTmpDir.exists()) {
            FileUtils.forceMkdir(_schemasTmpDir);
        }
        _vip = _controllerConf.generateVipUrl();
    } catch (Exception e) {
        throw new InvalidControllerConfigException("Bad controller configuration", e);
    }
}

From source file:com.meltmedia.cadmium.core.git.DelayedGitServiceInitializerTest.java

/**
 * Initializes the {@link GitService} reference to set into the {@link DelayedDelayedGitServiceInitializer}.
 * //from w w  w . j  a va  2 s . co m
 * @throws Exception
 */
@Before
public void initGitService() throws Exception {
    File testDir = new File("target/delayed-git-init-test");
    FileUtils.deleteQuietly(testDir);
    FileUtils.forceMkdir(testDir);
    gitInit = new DelayedGitServiceInitializer();
    GitService tmpGit = GitService.cloneRepo("git://github.com/meltmedia/cadmium.git",
            new File(testDir, "git-checkout").getAbsolutePath());
    tmpGit.switchBranch("cd-manual");
    tmpGit.resetToRev("3ddc7c498c940f49a1cc53aa3d98104a4d24eaa4");
    assertNotNull("GitService should not be null.", tmpGit);
    gitInit.setGitService(tmpGit);
}

From source file:com.datis.irc.kryo.KryoSerializerTest.java

@Override
protected void setUp() throws Exception {
    try {// w  ww.  j av a  2  s  .c  om
        System.out.println("DELETE and Create Folder");
        File f = new File(addressFolder);
        File fKryo = new File(addressFolder + "/kryo");
        File fpojo = new File(addressFolder + "/pojo");
        FileUtils.cleanDirectory(f); //clean out directory (this is optional -- but good know)
        FileUtils.forceDelete(f); //delete directory
        FileUtils.forceMkdir(f); //create directory
        FileUtils.forceMkdir(fKryo); //create directory
        FileUtils.forceMkdir(fpojo); //create directory
    } catch (IOException e) {
        System.out.println("ERROR in Create And Delete DirectoryS");
        e.printStackTrace();
    }
}

From source file:cat.calidos.morfeu.utils.Tezt.java

public String setupTempDirectory() throws Exception {

    String defaultTmp = "./target/integration-tests-tmp";
    String tmp = defineSystemVariable("TMP_FOLDER", defaultTmp);
    File tmpFolder = new File(tmp);
    if (tmpFolder.exists()) {
        if (tmpFolder.isFile()) {
            fail("Temporary folder destination exists and it's not a directory");
        }//  w ww . jav a  2 s .  c  o m
    } else {
        FileUtils.forceMkdir(tmpFolder);
    }

    return tmpFolder.getAbsolutePath();

}

From source file:com.cdancy.artifactory.rest.util.ArtifactoryUtils.java

public static File getGradleFile(GAVCoordinates gavCoordinates, String fileName, String etag) {
    File gradleFile = new File(getGradleFilesDir(), gavCoordinates.group + "/" + gavCoordinates.artifact + "/"
            + gavCoordinates.version + "/" + etag + "/" + fileName);
    if (!gradleFile.getParentFile().exists()) {
        try {/*from   www  .  j a  v  a 2 s .  c  o m*/
            FileUtils.forceMkdir(gradleFile.getParentFile());
        } catch (Exception e) {
            Throwables.propagate(e);
        }
    }

    return gradleFile;
}

From source file:com.BuildCraft.install.InstallMain.java

private void doInstall() {
    boolean installSuccessful = true;
    for (int i = 0; i < fileList.length; i++) {
        if (!fileList[i].exists()) {
            if (isDirectory[i]) {
                ConsoleOut.printMsgNNL("InstallMain: Creating directory " + fileList[i].getName() + "...");
                try {
                    FileUtils.forceMkdir(fileList[i]);
                    ConsoleOut.printMsg("Done!");
                } catch (Exception ex) {
                    installSuccessful = false;
                    ConsoleOut.printMsg("Failed!");
                }/*from   www  .j  av  a 2s  .c o m*/
            } else {
                ConsoleOut.printMsgNNL("InstallMain: Creating file " + fileList[i].getName() + "...");
                try {
                    FileUtils.touch(fileList[i]);
                    ConsoleOut.printMsg("Done!");
                } catch (Exception ex) {
                    installSuccessful = false;
                    ConsoleOut.printMsg("Failed!");
                }
            }
        }
    }
}

From source file:com.github.brandtg.switchboard.FileLogIndexer.java

/**
 * Creates an agent to index chunks of files.
 *///  w w  w  .j av a 2s.co m
public FileLogIndexer(FileLogServerConfig config, LogIndex logIndex) throws IOException {
    this.config = config;
    this.executorService = Executors.newSingleThreadExecutor();

    File rootDir = new File(config.getRootDir());
    if (!rootDir.exists()) {
        FileUtils.forceMkdir(rootDir);
        LOG.info("Created {}", rootDir);
    }

    // Find the current high water mark index among all files in directory
    long indexHighWaterMark = 0;
    File[] files = rootDir.listFiles();
    if (files != null) {
        for (File file : files) {
            LogRegion highWaterMark = logIndex.getHighWaterMark(file.getAbsolutePath());
            if (highWaterMark != null && highWaterMark.getIndex() > indexHighWaterMark) {
                indexHighWaterMark = highWaterMark.getIndex();
            }
        }
    }

    this.fileLogWatcher = new FileLogWatcher(config.getFilePrefix(), logIndex, indexHighWaterMark,
            config.getWaitSleepMillis(), config.getWaitTimeoutMillis());
}

From source file:com.graphaware.importer.data.location.FileLocator.java

/**
 * {@inheritDoc}/*from w  ww . jav a2 s .  co  m*/
 *
 * @return absolute path to a file.
 */
@Override
public String locate(Data data) {
    String location = super.locate(data);

    try {
        FileUtils.forceMkdir(new File(dir));
    } catch (IOException e) {
        throw new RuntimeException(e);
    }

    return new File(dir + File.separator + location + suffix()).getAbsolutePath();
}