List of usage examples for org.apache.commons.io FileUtils forceMkdir
public static void forceMkdir(File directory) throws IOException
From source file:net.siegmar.japtproxy.poolobject.PoolFile.java
/** * Initialize the PoolFile with the given resource. * * @param resource the file handle./*from w w w . j a v a 2 s . co m*/ * @throws IOException is thrown if the initialization fails. */ public PoolFile(final File resource, final RepoPackage repoPackage) throws IOException { this.resource = resource; this.repoPackage = repoPackage; tmpResource = new File(resource.getAbsolutePath() + ".tmp"); final File dir = resource.getParentFile(); FileUtils.forceMkdir(dir); }
From source file:fr.inria.atlanmod.neo4emf.neo4jresolver.runtimes.AbstractNeo4jRuntimeInstaller.java
public void install(IProgressMonitor monitor) throws IOException { if (monitor == null) { monitor = new NullProgressMonitor(); }// ww w .j av a 2 s.c om try { monitor.beginTask("Installing", 1); IPath runtimeDataAreaPath = Neo4JRuntimesManager.INSTANCE.getRuntimeDataArea(); IPath runtimePath = runtimeDataAreaPath.append(getVersion()).append(getId()); FileUtils.forceMkdir(runtimePath.toFile()); performInstall(new SubProgressMonitor(monitor, 1), runtimePath); Neo4JRuntimesManager.INSTANCE.initializeRuntimeMetadata(this, runtimePath); Neo4JRuntimesManager.INSTANCE.configureAsProjectPlugin(this, runtimePath); } finally { monitor.done(); } }
From source file:com.vmware.photon.controller.cloudstore.xenon.helpers.TestEnvironment.java
private TestEnvironment(int hostCount, HostClientFactory hostClientFactory, AgentControlClientFactory agentControlClientFactory) throws Throwable { assertTrue(hostCount > 0);/*from w w w . j av a 2s .c om*/ hosts = new PhotonControllerXenonHost[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); hosts[i] = new PhotonControllerXenonHost(xenonConfig, hostClientFactory, agentControlClientFactory, null, null); CloudStoreServiceGroup cloudStoreServiceGroup = new CloudStoreServiceGroup(); hosts[i].registerCloudStore(cloudStoreServiceGroup); } // Disable host ping: we have fake hosts and don't want them to be marked as missing HostService.setInUnitTests(true); TaskSchedulerServiceStateBuilder.triggerInterval = TimeUnit.MILLISECONDS.toMicros(500); }
From source file:hoot.services.HootServletContext.java
private static void createTileServerPath(String path) throws IOException { File file = new File(path); if (!file.exists()) { FileUtils.forceMkdir(file); }/*from w w w. j av a 2s . c o m*/ }
From source file:de.crowdcode.movmvn.core.Unzipper.java
/** * Unzip a file./*from w ww. j a v a 2s . c o m*/ * * @param archiveFile * to be unzipped * @param outPath * the place to put the result * @throws IOException * exception * @throws ZipException * exception */ public void unzipFileToDir(final File archiveFile, final File outPath) throws IOException, ZipException { ZipFile zipFile = new ZipFile(archiveFile); Enumeration<ZipArchiveEntry> e = zipFile.getEntries(); while (e.hasMoreElements()) { ZipArchiveEntry entry = e.nextElement(); File file = new File(outPath, entry.getName()); if (entry.isDirectory()) { FileUtils.forceMkdir(file); } else { InputStream is = zipFile.getInputStream(entry); FileOutputStream os = FileUtils.openOutputStream(file); try { IOUtils.copy(is, os); } finally { os.close(); is.close(); } file.setLastModified(entry.getTime()); } } }
From source file:azkaban.app.AzkabanApplicationTest.java
@Test public void testAddJobAndReload() throws Exception { String testJob = "testjob"; AzkabanApplication app = new AzkabanApplication(Arrays.asList(jobDir), logDir, tmpDir, false); Assert.assertEquals(0, app.getJobManager().loadJobDescriptors().size()); Assert.assertNull(app.getJobManager().getJobDescriptor(testJob)); File newJobDir = new File(jobDir, "test"); FileUtils.forceMkdir(newJobDir); File newJob = new File(newJobDir, testJob + ".job"); FileUtils.writeLines(newJob, Arrays.asList("type=command", "command=ls")); app.reloadJobsFromDisk();/* w ww.jav a 2 s .c om*/ Assert.assertEquals(1, app.getJobManager().loadJobDescriptors().size()); Job loadedJob = app.getJobManager().loadJob(testJob, true); Assert.assertEquals(testJob, loadedJob.getId()); Assert.assertTrue(loadedJob instanceof LoggingJob); Assert.assertTrue(((LoggingJob) loadedJob).getInnerJob() instanceof ProcessJob); }
From source file:ch.algotrader.util.io.CsvBarWriter.java
public CsvBarWriter(File file) throws IOException { File parent = file.getParentFile(); if (!parent.exists()) { FileUtils.forceMkdir(parent); }/*from www . jav a 2 s . c o m*/ boolean exists = file.exists(); this.writer = new CsvBeanWriter(new FileWriter(file, true), CsvPreference.EXCEL_PREFERENCE); if (!exists) { this.writer.writeHeader(header); } }
From source file:com.ewcms.publication.task.generator.TemplateTaskBase.java
@Override protected boolean initTask(List<DepTask> tasks, String id) { boolean success = false; try {/* w ww .j a va2s .c om*/ String path = String.format("%s/%s", tempRoot, id); dir = new File(path); FileUtils.forceMkdir(dir); success = true; } catch (IOException e) { dir = null; tasks.add(DepTask.error(id, "", e.getMessage())); tasks.add(DepTask.finish(id)); } return success; }
From source file:hudson.util.io.RewindableFileOutputStream.java
private synchronized OutputStream current() throws IOException { if (current == null) { if (!closed) { FileUtils.forceMkdir(out.getParentFile()); try { current = Files.newOutputStream(out.toPath(), StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); } catch (FileNotFoundException | NoSuchFileException | InvalidPathException e) { throw new IOException("Failed to open " + out, e); }//from www.j a v a2 s.c o m } else { throw new IOException(out.getName() + " stream is closed"); } } return current; }
From source file:com.vmware.photon.controller.scheduler.helpers.xenon.SchedulerTestEnvironment.java
/** * Constructs a test environment object. * * @throws Throwable Throws an exception if any error is encountered. *//*from w w w . j a va 2 s . co m*/ private SchedulerTestEnvironment(HostClientFactory hostClientFactory, SchedulerConfig config, ConstraintChecker constraintChecker, CloudStoreHelper cloudStoreHelper, int hostCount) throws Throwable { assertTrue(hostCount > 0); hosts = new PhotonControllerXenonHost[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); hosts[i] = new PhotonControllerXenonHost(xenonConfig, hostClientFactory, null, null, cloudStoreHelper, null); SchedulerServiceGroup schedulerServiceGroup = new SchedulerServiceGroup(config.getRoot(), constraintChecker); hosts[i].registerScheduler(schedulerServiceGroup); } }