List of usage examples for org.apache.commons.io FileUtils deleteDirectory
public static void deleteDirectory(File directory) throws IOException
From source file:kr.co.bitnine.octopus.schema.metamodel.EmbeddedElasticsearchServer.java
private void deleteDataDirectory() { try {//from w w w . j ava 2s . c om FileUtils.deleteDirectory(new File(dataDirectory)); } catch (IOException e) { throw new RuntimeException("Could not delete data directory of embedded elasticsearch server", e); } }
From source file:edu.umn.msi.tropix.common.test.Foo.java
@Test(groups = "unit") public void toStringTest() throws IOException { final String path = System.getProperty("java.io.tmpdir") + File.separator + "MooCow" + UUID.randomUUID().toString(); try {/*from ww w . j a v a 2 s. c om*/ final TempDirectoryCreatorImpl creator = new TempDirectoryCreatorImpl(path); assert creator.toString().contains("MooCow"); } finally { FileUtils.deleteDirectory(new File(path)); } }
From source file:jp.realglobe.util.uploader.DelayedWatcherTest.java
/** * @throws Exception /*from w w w .j a v a2s. c o m*/ */ @After public void tearDown() throws Exception { this.executor.shutdownNow(); FileUtils.deleteDirectory(this.directory.toFile()); }
From source file:com.blackberry.bdp.common.versioned.LocalZkServer.java
public LocalZkServer() throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException, ClassNotFoundException, IOException { String dataDirectory = System.getProperty("java.io.tmpdir"); dir = new File(dataDirectory, "zookeeper").getAbsoluteFile(); while (dir.exists()) { LOG.info("deleting {}", dir); FileUtils.deleteDirectory(dir); }/*from w ww . ja va2 s. c o m*/ server = new ZooKeeperServer(dir, dir, tickTime); // The class that we need changed name between CDH3 and CDH4, so let's // check // for the right version here. try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxnFactory"); standaloneServerFactory = factoryClass.newInstance(); Method configure = factoryClass.getMethod("configure", InetSocketAddress.class, Integer.TYPE); configure.invoke(standaloneServerFactory, new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e) { LOG.info("Did not find NIOServerCnxnFactory"); try { factoryClass = Class.forName("org.apache.zookeeper.server.NIOServerCnxn$Factory"); Constructor<?> constructor = factoryClass.getConstructor(InetSocketAddress.class, Integer.TYPE); standaloneServerFactory = constructor.newInstance(new InetSocketAddress(clientPort), numConnections); Method startup = factoryClass.getMethod("startup", ZooKeeperServer.class); startup.invoke(standaloneServerFactory, server); } catch (ClassNotFoundException e1) { LOG.info("Did not find NIOServerCnxn.Factory"); throw new ClassNotFoundException("Can't find NIOServerCnxnFactory or NIOServerCnxn.Factory"); } } }
From source file:com.hurence.logisland.processor.elasticsearch.EmbeddedElasticsearchServer.java
/** * Explicit Constructor./*from www .j a v a 2 s . co m*/ */ public EmbeddedElasticsearchServer(String homeDirectory) { try { FileUtils.deleteDirectory(new File(homeDirectory)); } catch (IOException e) { throw new RuntimeException("Unable to clean embedded elastic-search home dir", e); } this.homeDirectory = homeDirectory; Settings.Builder elasticsearchSettings = Settings.builder() .put("cluster.name", CLUSTER_NAME).put("node.name", "testNode").put("number_of_shards", 3) .put("number_of_replicas", 1).put("network.host", "local").put("node.data", true) .put("node.local", true).put("http.enabled", false).put("path.home", homeDirectory) .put("discovery.zen.ping_timeout", 0); // make startup faster /*# Using less filesystem as possible index.store.type=memory index.store.fs.memory.enabled=true index.gateway.type=none gateway.type=none*/ this.node = new Node(elasticsearchSettings.build()); }
From source file:com.ikanow.aleph2.core.shared.utils.TestDirUtils.java
@Before public void setupDependencies() throws Exception { _temp_dir = System.getProperty("java.io.tmpdir") + File.separator; //delete everything for this test: try {//from ww w . j a va2 s . com FileUtils.deleteDirectory(new File(_temp_dir + "/data/misc/")); } catch (Exception e) { } GlobalPropertiesBean globals = new GlobalPropertiesBean(_temp_dir, _temp_dir, _temp_dir, _temp_dir); // create folder structure if it does not exist for testing. IStorageService storage_service = new MockStorageService(globals); fileContext = storage_service.getUnderlyingPlatformDriver(FileContext.class, Optional.empty()).get(); logger.info("Root dir:" + _temp_dir); DirUtils.createDirectory(fileContext, _temp_dir + "/data/misc/bucket1/managed_bucket/import/ready"); DirUtils.createDirectory(fileContext, _temp_dir + "/data/misc/bucket2/managed_bucket/import/ready"); DirUtils.createDirectory(fileContext, _temp_dir + "/data/misc/bucket3/managed_bucket/import/ready"); DirUtils.createDirectory(fileContext, _temp_dir + "/data/misc/bucket_parent/bucket4/managed_bucket/import/ready"); DirUtils.createDirectory(fileContext, _temp_dir + "/data/misc/bucket_parent/onemore/bucket5/managed_bucket/import/ready"); new DirUtils(); //coverage! }
From source file:br.univali.celine.lms.integration.ContentPackageBuilder.java
public void build(String organizationName, String outputFileName) throws Exception { String sdir = tempDir + "/" + organizationName; File fdir = new File(sdir); FileUtils.deleteDirectory(new File(tempDir)); fdir.mkdirs();/* w ww. j a v a2s. c o m*/ ContentPackage cp = ContentPackage.buildBasic(organizationName, organizationName, new ContentPackageReader20043rd()); Organization org = cp.getOrganizations().getDefaultOrganization(); Zip zip = new Zip(); for (FileItem fi : fileItens) { zip.unzip(fi.zipFile, new File(sdir + "/" + fi.itemName)); Item20043rd item = Item20043rd.buildBasic(fi.itemName, fi.itemName); item.setIdentifierref("RES-" + fi.itemName); org.addItem(item); Resource res = new Resource(); res.setHref(fi.itemName + "/" + fi.itemFileRoot); res.setIdentifier(item.getIdentifierref()); res.setScormType("sco"); res.setType("webcontent"); cp.getResources().addResource(res); } FileUtils.writeStringToFile(new File(sdir + "/imsmanifest.xml"), cp.toString()); zip.zipDir(outputFileName, sdir); }
From source file:com.cj.restspecs.mojo.Util.java
public static void deleteDirectory(File directory) { try {/* w w w. j a va 2 s .co m*/ FileUtils.deleteDirectory(directory); } catch (Exception e) { throw new RuntimeException(e); } }
From source file:com.google.code.polymate.CRUDTests.java
@After public void tearDown() throws IOException { mongo.dropDatabase(MONGO_DB_NAME);// w w w . j a va2 s. com mongo.close(); neo.shutdown(); FileUtils.deleteDirectory(new File(NEO_DB_DIR)); }
From source file:io.druid.segment.loading.LocalDataSegmentKiller.java
@Override public void kill(DataSegment segment) throws SegmentLoadingException { final File path = getPath(segment); log.info("killing segment[%s] mapped to path[%s]", segment.getIdentifier(), path); try {//from ww w . j a va 2 s .co m if (path.getName().endsWith(".zip")) { // path format -- > .../dataSource/interval/version/partitionNum/xxx.zip File partitionNumDir = path.getParentFile(); FileUtils.deleteDirectory(partitionNumDir); //try to delete other directories if possible File versionDir = partitionNumDir.getParentFile(); if (versionDir.delete()) { File intervalDir = versionDir.getParentFile(); if (intervalDir.delete()) { File dataSourceDir = intervalDir.getParentFile(); dataSourceDir.delete(); } } } else { throw new SegmentLoadingException("Unknown file type[%s]", path); } } catch (IOException e) { throw new SegmentLoadingException(e, "Unable to kill segment"); } }