List of usage examples for org.apache.commons.io FileUtils forceMkdir
public static void forceMkdir(File directory) throws IOException
From source file:com.norconex.collector.http.sitemap.impl.SitemapStore.java
public SitemapStore(HttpCrawlerConfig config, boolean resume) { super();//from ww w .j av a 2 s .c o m LOG.info(config.getId() + ": Initializing sitemap store..."); this.config = config; String dbDir = config.getWorkDir().getPath() + "/sitemaps/" + config.getId() + "/"; try { FileUtils.forceMkdir(new File(dbDir)); } catch (IOException e) { throw new CollectorException("Cannot create sitemap directory: " + dbDir, e); } File dbFile = new File(dbDir + "mapdb"); boolean create = !dbFile.exists() || !dbFile.isFile(); // Configure and open database this.db = DBMaker.newFileDB(dbFile).asyncWriteEnable().cacheSoftRefEnable().closeOnJvmShutdown().make(); sitemaps = db.getHashSet(STORE_SITEMAP); if (resume) { LOG.debug(config.getId() + ": Re-using sitemap store."); } else if (!create) { LOG.debug(config.getId() + ": Cleaning sitemap store..."); sitemaps.clear(); db.commit(); } else { LOG.debug(config.getId() + ": Sitemap store created."); } LOG.info(config.getId() + ": Done initializing sitemap store."); }
From source file:com.github.brandtg.pantopod.crawler.FileBasedCrawlingEventHandler.java
@Override protected void handleExternalDomain(URI srcUrl, URI dstUrl) throws IOException { File srcRoot = new File(outputDir, srcUrl.getHost()); File extRoot = new File(srcRoot, EXT_FILE); File outputDir = new File(extRoot, dstUrl.getHost()); if (!outputDir.exists()) { FileUtils.forceMkdir(outputDir); }/*from w w w . j a v a 2 s .com*/ }
From source file:ch.algotrader.report.MapReporter.java
protected MapReporter(File file, String[] header, CellProcessor[] processor) { try {/* w w w . java 2s. c om*/ File parent = file.getParentFile(); if (!parent.exists()) { FileUtils.forceMkdir(parent); } this.header = header; this.processor = processor; this.writer = new CsvMapWriter(new FileWriter(file, false), CsvPreference.EXCEL_PREFERENCE); this.writer.writeHeader(header); ReportManager.registerReport(this); } catch (IOException e) { throw new ReportException(e); } }
From source file:fr.lirmm.yamplusplus.yampponline.TestSkosToOwlConverter.java
@Test public void testSkosToOwlConverter() throws IOException, ClassNotFoundException, OWLOntologyStorageException { FileUtils.forceMkdir(new File("/tmp/yam-gui")); String skosRameau = YamFileHandler.convertSkosToOwl(new File("src/test/resources/rameau.ttl"), new File("/tmp/yam-gui/rameau_converted.xml"), "RDF/XML"); String skosIaml = YamFileHandler.convertSkosToOwl(new File("src/test/resources/iaml.ttl"), new File("/tmp/yam-gui/iaml_converted.xml"), "RDF/XML"); String skosMimo = YamFileHandler.convertSkosToOwl(new File("src/test/resources/MIMO.xml"), new File("/tmp/yam-gui/mimo_converted.xml"), "RDF/XML"); OWLOntologyManager owlManager;/* www .j a v a 2s. com*/ OWLOntology ontology; // Test values boolean testSubClass = false; boolean testRdfsLabel = false; // Load the generated OWL ontology owlManager = OWLManager.createOWLOntologyManager(); try { ontology = owlManager.loadOntologyFromOntologyDocument( new ByteArrayInputStream(skosRameau.getBytes(StandardCharsets.UTF_8))); for (OWLClass cls : ontology.getClassesInSignature()) { for (OWLClassExpression subClsExpr : cls.getSubClasses(ontology)) { OWLClass subCls = subClsExpr.asOWLClass(); // Check for a subClass of a Class to see if well created if (cls.getIRI().toString().equals("http://data.bnf.fr/ark:/12148/cb16688937f") && subCls.getIRI().toString().equals("http://data.bnf.fr/ark:/12148/cb16742478j")) { testSubClass = true; } } for (OWLAnnotation annotation : cls.getAnnotations(ontology)) { // Check for a rdfs:label to see if well created if (cls.getIRI().toString().equals("http://data.bnf.fr/ark:/12148/cb151095953") && annotation.getProperty().getIRI().toString() .equals("http://www.w3.org/2000/01/rdf-schema#label") && annotation.getValue().toString().equals("\"Violon lectrique\"")) { testRdfsLabel = true; } } } } catch (OWLOntologyCreationException ex) { Logger.getLogger(TestSkosToOwlConverter.class.getName()).log(Level.SEVERE, null, ex); } //MainProgram.match(outputFile1.getAbsolutePath(), outputFile2.getAbsolutePath(), "/tmp/yam-gui/yam_matcher_results.rdf"); assertTrue(true); assertTrue(testSubClass); assertTrue(testRdfsLabel); }
From source file:com.github.neio.filesystem.paths.TestDirectoryPath.java
@Before public void before() throws IOException { FileUtils.forceMkdir(testDir); }
From source file:com.vmware.photon.controller.cloudstore.dcp.helpers.TestEnvironment.java
private TestEnvironment(int hostCount) throws Throwable { assertTrue(hostCount > 0);/*from w w w . j a v a 2 s. c om*/ hosts = new CloudStoreXenonHost[hostCount]; for (int i = 0; i < hosts.length; i++) { String sandbox = generateStorageSandboxPath(); FileUtils.forceMkdir(new File(sandbox)); XenonConfig xenonConfig = new XenonConfig(); xenonConfig.setBindAddress(BIND_ADDRESS); xenonConfig.setPort(0); xenonConfig.setStoragePath(sandbox); BuildInfo buildInfo = BuildInfo.get(this.getClass()); hosts[i] = new CloudStoreXenonHost(xenonConfig, mock(HostClientFactory.class), mock(AgentControlClientFactory.class), mock(ServiceConfigFactory.class), buildInfo); } // Disable host ping: we have fake hosts and don't want them to be marked as missing HostService.setInUnitTests(true); }
From source file:com.francetelecom.clara.cloud.mvn.consumer.maven.PomGenerator.java
public File generatePom(File projectDirectory, MavenReference mavenReference) throws IOException { if (projectDirectory == null) { throw new IllegalArgumentException("projectDirectory cannot be null"); }/* w w w . j av a 2 s.c o m*/ if (mavenReference == null) { throw new IllegalArgumentException("mavenReference cannot be null"); } if (!projectDirectory.exists()) { FileUtils.forceMkdir(projectDirectory); } Model project = new Model(); project.setModelVersion("4.0.0"); project.setGroupId(mavenReference.getGroupId()); project.setArtifactId(mavenReference.getArtifactId()); project.setVersion(mavenReference.getVersion()); project.setPackaging(mavenReference.getExtension()); project.setName(mavenReference.getArtifactId() + " (" + mavenReference.getExtension() + ")"); String pom = modelToStringXml(project); logger.debug("generated pom : \n" + pom); File pomFile = new File(projectDirectory.getAbsolutePath() + "/pom.xml"); FileUtils.writeStringToFile(pomFile, pom); return pomFile; }
From source file:com.jivesoftware.os.miru.service.locator.MiruResourceLocatorInitializer.java
public MiruResourceLocator initialize(final MiruServiceConfig config) throws IOException { File[] residentDiskPaths = pathToFile(config.getDiskResourceLocatorPaths().split(",")); for (File residentDiskPath : residentDiskPaths) { FileUtils.forceMkdir(residentDiskPath); }// w w w. jav a 2s. c o m final File[] checkThese = new File[residentDiskPaths.length + 1]; System.arraycopy(residentDiskPaths, 0, checkThese, 0, residentDiskPaths.length); checkThese[checkThese.length - 1] = new File(System.getProperty("user.dir")); HealthFactory.scheduleHealthChecker(ResidentResourceDiskCheck.class, config1 -> (HealthChecker) new DiskFreeHealthChecker(config1, checkThese)); final MiruResourceLocator residentDiskResourceLocator = new DiskIdentifierPartResourceLocator( residentDiskPaths, config.getOnDiskInitialChunkSize(), config.getInMemoryChunkSize()); final File[] transientPaths = pathToFile(config.getTransientResourceLocatorPaths().split(",")); for (File transientPath : transientPaths) { FileUtils.forceMkdir(transientPath); } return residentDiskResourceLocator; }
From source file:net.mindengine.blogix.tests.acceptance.ExporterAccTest.java
@BeforeClass public void init() throws IOException { destinationDir = new File("target" + File.separator + "exported-routes"); if (destinationDir.exists()) { FileUtils.cleanDirectory(destinationDir); } else {/* w w w . j av a 2 s . c o m*/ FileUtils.forceMkdir(destinationDir); } }
From source file:com.github.ipaas.ideploy.agent.handler.BackupCodeHandler.java
@Override public void execute(String flowId, String cmd, Map<String, Object> params, BundleContext bundleContext) throws Exception { logger.debug("? flowId:" + flowId + " cmd:" + cmd + " params:" + params); String srcPath = String.valueOf(params.get("srcPath")); String targetPath = String.valueOf(params.get("targetPath")); File srcDir = new File(srcPath); // ?/* www . j av a 2 s.com*/ if (!srcDir.exists()) { return; } File destDir = new File(targetPath); // if (destDir.exists() || destDir.getParentFile().exists()) { FileUtils.cleanDirectory(destDir.getParentFile()); } else { FileUtils.forceMkdir(destDir); } // FileUtils.copyDirectory(srcDir, destDir); logger.debug("??..."); }