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.uci.ics.pregelix.core.util.PregelixHyracksIntegrationUtil.java

public static void init() throws Exception {
    FileUtils.forceMkdir(new File("dev1"));
    FileUtils.forceMkdir(new File("dev2"));
    FileUtils.forceMkdir(new File("dev3"));
    FileUtils.forceMkdir(new File("dev4"));
    CCConfig ccConfig = new CCConfig();
    ccConfig.clientNetIpAddress = CC_HOST;
    ccConfig.clusterNetIpAddress = CC_HOST;
    ccConfig.clusterNetPort = TEST_HYRACKS_CC_PORT;
    ccConfig.clientNetPort = TEST_HYRACKS_CC_CLIENT_PORT;
    ccConfig.httpPort = 12001;//from   w  ww . java  2  s.c o m
    ccConfig.defaultMaxJobAttempts = 0;
    ccConfig.jobHistorySize = 1;
    ccConfig.profileDumpPeriod = -1;
    ccConfig.heartbeatPeriod = 500;
    ccConfig.maxHeartbeatLapsePeriods = 20;

    // cluster controller
    cc = new ClusterControllerService(ccConfig);
    cc.start();

    // two node controllers
    NCConfig ncConfig1 = new NCConfig();
    ncConfig1.ccHost = "localhost";
    ncConfig1.clusterNetIPAddress = "localhost";
    ncConfig1.ccPort = TEST_HYRACKS_CC_PORT;
    ncConfig1.dataIPAddress = "127.0.0.1";
    ncConfig1.resultIPAddress = "127.0.0.1";
    ncConfig1.nodeId = NC1_ID;
    ncConfig1.ioDevices = "dev1,dev2";
    ncConfig1.appNCMainClass = NCApplicationEntryPoint.class.getName();
    ncConfig1.appArgs = Arrays.asList("32768", "131072");
    nc1 = new NodeControllerService(ncConfig1);
    nc1.start();

    NCConfig ncConfig2 = new NCConfig();
    ncConfig2.ccHost = "localhost";
    ncConfig2.clusterNetIPAddress = "localhost";
    ncConfig2.ccPort = TEST_HYRACKS_CC_PORT;
    ncConfig2.dataIPAddress = "127.0.0.1";
    ncConfig2.resultIPAddress = "127.0.0.1";
    ncConfig2.nodeId = NC2_ID;
    ncConfig2.appNCMainClass = NCApplicationEntryPoint.class.getName();
    ncConfig2.ioDevices = "dev3,dev4";
    ncConfig2.appArgs = Arrays.asList("32768", "131072");
    nc2 = new NodeControllerService(ncConfig2);
    nc2.start();

    // hyracks connection
    hcc = new HyracksConnection(CC_HOST, TEST_HYRACKS_CC_CLIENT_PORT);
    ClusterConfig.loadClusterConfig(CC_HOST, TEST_HYRACKS_CC_CLIENT_PORT);
}

From source file:it.marcoberri.mbmeteo.action.Commons.java

public static void importLogPywws(Logger log) {
    try {/*from   www . j a  va2  s . com*/

        final File importPath = new File(ConfigurationHelper.prop.getProperty("import.loggerPywws.filepath"));
        FileUtils.forceMkdir(importPath);
        final File importPathBackup = new File(
                ConfigurationHelper.prop.getProperty("import.loggerPywws.filepath") + File.separator + "old"
                        + File.separator);
        FileUtils.forceMkdir(importPathBackup);
        boolean hasHeader = Default
                .toBoolean(ConfigurationHelper.prop.getProperty("import.loggerPywws.hasHeader"), false);

        final String[] extension = { "csv", "txt" };
        Collection<File> files = FileUtils.listFiles(importPath, extension, false);

        if (files.isEmpty()) {
            log.debug("No file to inport: " + importPath);
            return;
        }

        for (File f : files) {
            log.debug("read file:" + f);

            final List<String> l = FileUtils.readLines(f, "UTF-8");
            log.debug("tot line:" + l.size());

        }

    } catch (Exception ex) {
        log.fatal(ex);

    }
}

From source file:hoot.services.controllers.info.AdvancedOptResourceTest.java

@BeforeClass
public static void beforeClass() throws Exception {
    original_HOME_FOLDER = HOME_FOLDER;//from  ww  w .j av a 2  s.c  o  m
    homeFolder = new File(FileUtils.getTempDirectory(), "AdvancedOptResourceTest");
    FileUtils.forceMkdir(homeFolder);
    assertTrue(homeFolder.exists());
    HootCustomPropertiesSetter.setProperty("HOME_FOLDER", homeFolder.getAbsolutePath());

    File testFolder = new File(homeFolder, "conf");
    FileUtils.forceMkdir(testFolder);

    File dest = new File(testFolder, "services/conflationRefOps.json");
    URL inputUrl = AdvancedOptResourceTest.class
            .getResource("/hoot/services/controllers/info/conflationRefOps.json");
    FileUtils.copyURLToFile(inputUrl, dest);

    dest = new File(testFolder, "services/conflateAdvOps.json");
    inputUrl = AdvancedOptResourceTest.class.getResource("/hoot/services/controllers/info/conflateAdvOps.json");
    FileUtils.copyURLToFile(inputUrl, dest);

    dest = new File(testFolder, "services/conflationAverageOps.json");
    inputUrl = AdvancedOptResourceTest.class
            .getResource("/hoot/services/controllers/info/conflationAverageOps.json");
    FileUtils.copyURLToFile(inputUrl, dest);

    dest = new File(testFolder, "services/conflationHorizontalOps.json");
    inputUrl = AdvancedOptResourceTest.class
            .getResource("/hoot/services/controllers/info/conflationHorizontalOps.json");
    FileUtils.copyURLToFile(inputUrl, dest);

    dest = new File(testFolder, "core/ConfigOptions.asciidoc");
    inputUrl = AdvancedOptResourceTest.class
            .getResource("/hoot/services/controllers/info/ConfigOptions.asciidoc");
    FileUtils.copyURLToFile(inputUrl, dest);
}

From source file:com.linkedin.pinot.core.data.readers.JSONRecordReaderTest.java

@BeforeClass
public void setUp() throws Exception {
    FileUtils.forceMkdir(TEMP_DIR);

    try (FileWriter fileWriter = new FileWriter(DATA_FILE)) {
        for (Object[] record : RECORDS) {
            JSONObject jsonRecord = new JSONObject();
            if (record[0] != null) {
                jsonRecord.put(COLUMNS[0], record[0]);
            }/*from   w  w w  .  j av a 2s.  c  o m*/
            if (record[1] != null) {
                jsonRecord.put(COLUMNS[1], new JSONArray(record[1]));
            }
            fileWriter.write(jsonRecord.toString());
        }
    }
}

From source file:com.netsteadfast.greenstep.util.PdfConvertUtils.java

@SuppressWarnings("unchecked")
public static List<File> toImageFiles(File pdfFile, int resolution) throws Exception {
    PDDocument document = PDDocument.loadNonSeq(pdfFile, null);
    List<PDPage> pages = document.getDocumentCatalog().getAllPages();
    File tmpDir = new File(Constants.getWorkTmpDir() + "/" + PdfConvertUtils.class.getSimpleName() + "/"
            + System.currentTimeMillis() + "/");
    FileUtils.forceMkdir(tmpDir);
    List<File> files = new LinkedList<File>();
    int len = String.valueOf(pages.size() + 1).length();
    for (int i = 0; i < pages.size(); i++) {
        String name = StringUtils.leftPad(String.valueOf(i + 1), len, "0");
        BufferedImage bufImage = pages.get(i).convertToImage(BufferedImage.TYPE_INT_RGB, resolution);
        File imageFile = new File(tmpDir.getPath() + "/" + name + ".png");
        FileOutputStream fos = new FileOutputStream(imageFile);
        ImageIOUtil.writeImage(bufImage, "png", fos, resolution);
        fos.flush();/*from w w  w  .  j av a2  s . c o m*/
        fos.close();
        files.add(imageFile);
    }
    document.close();
    tmpDir = null;
    return files;
}

From source file:gov.nih.nci.restgen.util.GeneratorUtil.java

public static void createOutputDir(String _outputDir) {
    try {//w w  w . j a va  2s .  c  om
        File file = new File(_outputDir);

        if (!file.exists() == true) {
            FileUtils.forceMkdir(file);
        }
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}

From source file:com.linkedin.pinot.core.data.readers.CSVRecordReaderTest.java

@BeforeClass
public void setUp() throws Exception {
    FileUtils.forceMkdir(TEMP_DIR);

    try (FileWriter fileWriter = new FileWriter(DATA_FILE);
            CSVPrinter csvPrinter = new CSVPrinter(fileWriter, CSVFormat.DEFAULT.withHeader(COLUMNS))) {
        for (Object[] record : RECORDS) {
            csvPrinter.printRecord(record[0],
                    StringUtils.join((int[]) record[1], CSVRecordReaderConfig.DEFAULT_MULTI_VALUE_DELIMITER));
        }/*from  w  w w.  ja  v  a 2 s . c o m*/
    }
}

From source file:com.ifeng.computing.batch.job.tasklet.ArchiveLogDataImportFileTasklet.java

@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
    // Make our destination directory and copy our input file to it
    File archiveDir = new File("archive");
    FileUtils.forceMkdir(archiveDir);
    FileUtils.copyFileToDirectory(new File(inputFile), archiveDir);

    // We're done...
    return RepeatStatus.FINISHED;
}

From source file:com.izforge.izpack.event.AntActionLogBuildListener.java

public AntActionLogBuildListener(File logFile, boolean append, int level) {
    this.setMessageOutputLevel(level);
    if (logFile != null) {
        PrintStream printStream;/*  www. j  a va 2 s . c  om*/
        try {
            final File canonicalLogFile = logFile.getCanonicalFile();
            FileUtils.forceMkdir(canonicalLogFile.getParentFile());
            FileUtils.touch(canonicalLogFile);
            printStream = new PrintStream(new FileOutputStream(canonicalLogFile, append));
            this.setOutputPrintStream(printStream);
            this.setErrorPrintStream(printStream);
        } catch (IOException e) {
            logger.warning("Cannot log to file '" + logFile + "': " + e.getMessage());
            this.setOutputPrintStream(System.out);
            this.setErrorPrintStream(System.err);
        }
    } else {
        this.setOutputPrintStream(System.out);
        this.setErrorPrintStream(System.err);
    }
}

From source file:com.talis.entity.db.babudb.BabuDbEntityDatabaseConcurrencyTest.java

@Before
public void setup() throws Exception {
    tmpDirs = new File[NUM_DBS];
    for (int i = 0; i < NUM_DBS; i++) {
        File tmpDir = new File(FileUtils.getTempDirectory(), "db-con-test-" + i);
        FileUtils.forceMkdir(tmpDir);
        FileUtils.cleanDirectory(tmpDir);
        tmpDirs[i] = tmpDir;/*w w  w .  j av a2  s  . co  m*/
    }
    super.setup();
}