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.druid.segment.writeout.TmpFileSegmentWriteOutMedium.java

TmpFileSegmentWriteOutMedium(File outDir) throws IOException {
    File tmpOutputFilesDir = new File(outDir, "tmpOutputFiles");
    FileUtils.forceMkdir(tmpOutputFilesDir);
    closer.register(() -> FileUtils.deleteDirectory(tmpOutputFilesDir));
    this.dir = tmpOutputFilesDir;
}

From source file:io.github.proxyprint.kitchen.config.DocumentsConfig.java

@Bean(name = "documentsPath")
public String configDocumentsPath() throws IOException {
    if (Document.DIRECTORY_PATH == null)
        Document.DIRECTORY_PATH = this.filesPath;
    File file = new File(Document.DIRECTORY_PATH);
    FileUtils.forceMkdir(file);
    return Document.DIRECTORY_PATH;
}

From source file:com.francetelecom.clara.cloud.mvn.consumer.MvnConsumerConfigurerTest.java

@Before
public void setup() throws IOException {
    this.mvnConsumerConfigurer = new MvnConsumerConfigurer();
    mvnConsumerConfigurer.setPullRepositoryUrls(new String[] { "http://repo1.com", "http://repo2.com" });

    File dummyLocalRepo = new File("target/dummy-local-repo/");
    FileUtils.forceMkdir(dummyLocalRepo);
    this.mvnConsumerConfigurer.setLocalM2RepoPath(dummyLocalRepo);

    File templateFile = new File("target" + File.separator + "templateFile.xml");
    templateFile.createNewFile();//from w ww.  j a  v  a  2s  .  c  o  m
    this.mvnConsumerConfigurer.setAssemblyTemplateFile(new FileInputStream(templateFile));
    templateFile.deleteOnExit();
}

From source file:ml.shifu.shifu.fs.ShifuFileUtilsTest.java

@Test
public void getDataScannersTest() throws IOException {

    File file = new File("common-utils");
    if (file.exists()) {
        FileUtils.deleteDirectory(file);
    }//from w  w  w .  ja v a  2s .  c  om
    FileUtils.forceMkdir(file);

    List<Scanner> list = ShifuFileUtils.getDataScanners(Arrays.asList(new String[] { "common-utils" }),
            SourceType.HDFS);

    Assert.assertTrue(list.size() == 0);

    file = new File("common-utils/part-0000");
    FileUtils.touch(file);

    list = ShifuFileUtils.getDataScanners(Arrays.asList(new String[] { "common-utils" }), SourceType.HDFS);

    Assert.assertTrue(list.size() == 1);

    for (Scanner scanner : list) {
        scanner.close();
    }

    FileUtils.deleteDirectory(new File("common-utils"));
}

From source file:com.yolodata.tbana.hadoop.mapred.CSVReaderTest.java

@Before
public void setUp() throws IOException {
    FileUtils.deleteDirectory(new File(TestUtils.TEST_FILE_PATH));
    FileUtils.forceMkdir(new File(TestUtils.TEST_FILE_PATH));
    actual = new ArrayList<Text>();
    expected = new ArrayList<Text>();
}

From source file:com.datatorrent.stram.cli.ApexCliTest.java

@BeforeClass
public static void createPackages() {
    userHome = System.getProperty("user.home");
    String newHome = System.getProperty("user.dir") + "/target";
    try {//from  ww w  .  j a  v  a2  s  .  c om

        FileUtils.forceMkdir(new File(newHome + "/.dt"));
        FileUtils.copyFile(
                new File(System.getProperty("user.dir") + "/src/test/resources/testAppPackage/dt-site.xml"),
                new File(newHome + "/.dt/dt-site.xml"));
        env.put("HOME", newHome);
        StramTestSupport.setEnv(env);
        // Set up jar file to use with constructor
        testFolder.create();

        appFile = StramTestSupport.createAppPackageFile();
        configFile = StramTestSupport.createConfigPackageFile(new File(testFolder.getRoot(), configJarPath));

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.opengamma.util.ZipUtils.java

/**
 * Unzips a ZIP archive./*  w w  w.jav a 2  s . c  om*/
 * 
 * @param zipFile  the archive file, not null
 * @param outputDir  the output directory, not null
 */
public static void unzipArchive(final ZipFile zipFile, final File outputDir) {
    ArgumentChecker.notNull(zipFile, "zipFile");
    ArgumentChecker.notNull(outputDir, "outputDir");

    try {
        Enumeration<? extends ZipEntry> entries = zipFile.entries();
        while (entries.hasMoreElements()) {
            ZipEntry entry = entries.nextElement();
            if (entry.isDirectory()) {
                FileUtils.forceMkdir(new File(outputDir, entry.getName()));
                continue;
            }
            File entryDestination = new File(outputDir, entry.getName());
            entryDestination.getParentFile().mkdirs();
            InputStream in = zipFile.getInputStream(entry);
            OutputStream out = new FileOutputStream(entryDestination);
            IOUtils.copy(in, out);
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(out);
        }
        zipFile.close();
    } catch (IOException ex) {
        throw new OpenGammaRuntimeException(
                "Error while extracting file: " + zipFile.getName() + " to: " + outputDir, ex);
    }
}

From source file:algorithm.AbstractAlgorithmTest.java

@Before
public void setUp() {
    File testDir1 = new File(RESTORED_DIRECTORY);
    File testDir2 = new File(OUTPUT_DIRECTORY);
    if (!testDir1.exists()) {
        try {/*from w w w. j  a  v a 2  s . c  om*/
            FileUtils.forceMkdir(testDir1);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    if (!testDir2.exists()) {
        try {
            FileUtils.forceMkdir(testDir2);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:gndata.lib.srv.LocalFileTest.java

@Before
public void setUp() throws Exception {
    // create directories
    File testDirs = testFileFolderChild.toFile();
    FileUtils.forceMkdir(testDirs);
    File parallelDir = testParallelFolder.toFile();
    FileUtils.forceMkdir(parallelDir);/*from w w  w  .  j  av  a 2  s.  c o m*/

    // create testfiles
    File testFile = testFileFolder.resolve(testFileName).toFile();
    FileUtils.write(testFile, "This is a normal test file");

    File testHiddenFile = testFileFolder.resolve("." + testFileName).toFile();
    FileUtils.write(testHiddenFile, "This is a hidden test file");

    //Set hidden attribute for Win OS systems
    if (SystemUtils.IS_OS_WINDOWS) {
        Files.setAttribute(Paths.get(testHiddenFile.getPath()), "dos:hidden", true);
    }

    localFile = new LocalFile(testLocalFilePath);

    localHiddenFile = new LocalFile(testFileFolder.resolve("." + testFileName));

    localDir = new LocalFile(testFileFolder);
}

From source file:com.datatorrent.stram.cli.DTCliTest.java

@BeforeClass
public static void starting() {
    try {/* w w w .j  av  a 2 s  .  co  m*/
        userHome = System.getProperty("user.home");
        String newHome = System.getProperty("user.dir") + "/target";
        FileUtils.forceMkdir(new File(newHome + "/.dt"));
        FileUtils.copyFile(
                new File(System.getProperty("user.dir") + "/src/test/resources/testAppPackage/dt-site.xml"),
                new File(newHome + "/.dt/dt-site.xml"));
        env.put("HOME", newHome);
        setEnv(env);

        cli.init();
        // Set up jar file to use with constructor
        testFolder.create();
        appFile = StramTestSupport.createAppPackageFile();
        configFile = StramTestSupport.createConfigPackageFile(new File(testFolder.getRoot(), configJarPath));
        ap = new AppPackage(appFile, true);
        cp = new ConfigPackage(configFile);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}