List of usage examples for org.apache.commons.io FileUtils forceMkdir
public static void forceMkdir(File directory) throws IOException
From source file:com.github.jrh3k5.flume.mojo.internal.AbstractUnitTest.java
/** * Get the test directory./*from ww w . j a v a 2s.c om*/ * * @return A {@link File} referencing a temporary directory isolated to this test. * @throws IOException * If any errors occur while creating (if needed) the test directory. */ protected File getTestDirectory() throws IOException { final File classDirectory = new File("target", getClass().getSimpleName()); FileUtils.forceMkdir(classDirectory); final File testDirectory = new File(classDirectory, getTestName()); FileUtils.forceMkdir(testDirectory); return testDirectory; }
From source file:de.codecentric.elasticsearch.plugin.kerberosrealm.support.EmbeddedKRBServer.java
public void start(final File workDir) throws Exception { simpleKdcServer = new SimpleKdcServer(); simpleKdcServer.enableDebug();//from ww w . j a v a 2s .c o m simpleKdcServer.setKdcTcpPort(NetworkUtil.getServerPort()); simpleKdcServer.setKdcUdpPort(NetworkUtil.getServerPort()); simpleKdcServer.setAllowTcp(true); simpleKdcServer.setAllowUdp(true); simpleKdcServer.setKdcRealm(realm); simpleKdcServer.setKdcHost("localhost"); FileUtils.forceMkdir(workDir); simpleKdcServer.setWorkDir(workDir); simpleKdcServer.setInnerKdcImpl(new NettyKdcServerImpl(simpleKdcServer.getKdcSetting())); simpleKdcServer.init(); //System.setErr(new PrintStream(new NullOutputStream())); simpleKdcServer.start(); }
From source file:com.github.rodionmoiseev.c10n.test.utils.UsingTmpDir.java
@Before @Override protected void before() throws Throwable { FileUtils.forceMkdir(dir); }
From source file:com.vmware.photon.controller.dhcpagent.xenon.helpers.TestEnvironment.java
private TestEnvironment(DHCPDriver dhcpDriver, int hostCount, ListeningExecutorService listeningExecutorService) throws Throwable { assertTrue(hostCount > 0);/* www. ja v a 2s . co m*/ hosts = new DHCPAgentXenonHost[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 DHCPAgentXenonHost(xenonConfig, buildInfo, listeningExecutorService, dhcpDriver); } }
From source file:com.dhenton9000.file.FileWatchers.java
public FileWatchers(String baseFolder, String fileExtension, IReaderSink sink) { //create the folders under neath the base folder outputDir = new File(baseFolder + "/output"); tempDir = new File(baseFolder + "/tempDir"); this.sink = sink; try {/* www . j a va2 s . c om*/ if (!outputDir.exists()) { FileUtils.forceMkdir(outputDir); } if (!tempDir.exists()) { FileUtils.forceMkdir(tempDir); } } catch (IOException ee) { throw new RuntimeException(ee.getMessage()); } //input folder should exist already inputDir = new File(baseFolder + "/input"); if (!inputDir.exists()) { throw new RuntimeException("cant find input folder"); } this.fileExtension = fileExtension; }
From source file:gov.usgs.cida.coastalhazards.rest.data.util.MetadataUtilTest.java
@BeforeClass public static void setUpClass() throws IOException { workDir = new File(tempDir, String.valueOf(new Date().getTime())); FileUtils.deleteQuietly(workDir);/* ww w . j a va 2 s . c o m*/ FileUtils.forceMkdir(workDir); }
From source file:com.linkedin.pinot.common.utils.TarGzCompressionUtilsTest.java
@BeforeMethod public void setUpTest() throws IOException { TEST_DIR = Files.createTempDirectory(TarGzCompressionUtils.class.getName()).toFile(); TEST_DIR.deleteOnExit();/* www . jav a 2s. com*/ dataDir = new File(TEST_DIR, "dataDir"); tarDir = new File(TEST_DIR, "tarDir"); untarDir = new File(TEST_DIR, "untarDir"); segmentDir = new File(dataDir, SEGMENT_NAME); FileUtils.forceMkdir(dataDir); FileUtils.forceMkdir(tarDir); FileUtils.forceMkdir(untarDir); FileUtils.forceMkdir(segmentDir); }
From source file:ch.algotrader.report.ListReporter.java
public ListReporter(File file, String[] header, CellProcessor[] processor) throws IOException { File parent = file.getParentFile(); if (!parent.exists()) { FileUtils.forceMkdir(parent); }//from w w w .java 2s . c om this.processor = processor; this.writer = new CsvListWriter(new FileWriter(file, false), CsvPreference.EXCEL_PREFERENCE); this.writer.writeHeader(header); ReportManager.registerReport(this); }
From source file:net.mindengine.blogix.tests.acceptance.CompilerAccTest.java
@BeforeClass public void beforeClass() throws IOException { if (compilerOutputDir.exists()) { FileUtils.cleanDirectory(compilerOutputDir); } else {//www .j ava 2s. c om FileUtils.forceMkdir(compilerOutputDir); } }
From source file:com.baifendian.swordfish.webserver.service.storage.FileSystemStorageService.java
/** * ?, /*w ww . j av a 2 s.co m*/ * * @param file * @param destFilename */ @Override public void store(MultipartFile file, String destFilename) { try { if (file.isEmpty()) { throw new StorageException("Failed to store empty file " + file.getOriginalFilename()); } File destFile = new File(destFilename); File destDir = new File(destFile.getParent()); if (!destDir.exists()) { FileUtils.forceMkdir(destDir); } Files.copy(file.getInputStream(), Paths.get(destFilename)); } catch (IOException e) { throw new StorageException("Failed to store file " + file.getOriginalFilename(), e); } }