List of usage examples for org.apache.commons.io FileUtils forceDelete
public static void forceDelete(File file) throws IOException
From source file:com.opengamma.transport.TaxonomyGatheringFudgeMessageSenderTest.java
@Test(timeOut = 20000) public void validFileLoadingOnStartup() throws IOException, InterruptedException { File tmpFile = File.createTempFile("TaxonomyGatheringFudgeMessageSenderTest_validFileLoadingOnStartup", ".properties"); FileUtils.forceDelete(tmpFile); FileUtils.forceDeleteOnExit(tmpFile); FudgeContext context = new FudgeContext(); CollectingFudgeMessageReceiver collectingReceiver = new CollectingFudgeMessageReceiver(); ByteArrayFudgeMessageReceiver fudgeReceiver = new ByteArrayFudgeMessageReceiver(collectingReceiver); DirectInvocationByteArrayMessageSender byteArraySender = new DirectInvocationByteArrayMessageSender( fudgeReceiver);// ww w . j a va 2 s .c o m ByteArrayFudgeMessageSender fudgeSender = new ByteArrayFudgeMessageSender(byteArraySender, context); TaxonomyGatheringFudgeMessageSender gatheringSender = new TaxonomyGatheringFudgeMessageSender(fudgeSender, tmpFile.getAbsolutePath(), context, 1000L); MutableFudgeMsg msg1 = context.newMessage(); msg1.add("name1", 1); msg1.add("name2", 1); msg1.add("name3", 1); msg1.add("name1", 1); MutableFudgeMsg msg2 = context.newMessage(); msg1.add("name4", msg2); msg2.add(14, 1); msg2.add("name5", "foo"); gatheringSender.send(msg1); gatheringSender.waitForNextWrite(); gatheringSender.getTimer().cancel(); // Now reload the file. gatheringSender = new TaxonomyGatheringFudgeMessageSender(fudgeSender, tmpFile.getAbsolutePath(), context, 5000L); assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name1")); assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name2")); assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name3")); assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name4")); assertTrue(gatheringSender.getCurrentTaxonomy().containsKey("name5")); assertEquals(5, gatheringSender.getCurrentTaxonomy().size()); }
From source file:jmassivesort.algs.chunks.SequentialChunkReader_LF_ASCII_Test.java
private void readChunkByChunk(int minChunkSz, int maxChunkSz, int inc, File src, String outFileName) throws IOException { for (int i = minChunkSz; i <= maxChunkSz; i += inc) { File out = createTmpFile(src.getParent(), outFileName + "_" + i); try (BufferedOutputStream outWr = new BufferedOutputStream(new FileOutputStream(out))) { readAllChunksAndWriteToOutput(i, src, outWr); outWr.close();//from www. jav a2s. c o m assertEquals("failed on chunkSize=" + i, FileUtils.checksumCRC32(src), FileUtils.checksumCRC32(out)); FileUtils.forceDelete(out); } } }
From source file:com.keybox.manage.util.SSHUtil.java
/** * delete SSH keys/*www . j av a 2 s .c o m*/ */ public static void deletePvtGenSSHKey() { //delete private key try { File file = new File(PVT_KEY); FileUtils.forceDelete(file); } catch (Exception ex) { } }
From source file:com.smash.revolance.ui.database.FileSystemStorage.java
@Override public void clear() throws StorageException { try {/*from w w w .j a va 2 s . c om*/ FileUtils.forceDelete(databaseFolder); databaseFolder.mkdirs(); } catch (IOException e) { throw new StorageException("Unable to clear storage system.", e); } }
From source file:com.ipcglobal.fredimport.process.ProcessReadmeSeriesId.java
/** * Process./*from ww w . jav a 2 s.c o m*/ * * @throws Exception the exception */ public void process() throws Exception { try { FileUtils.forceDelete(new File(outputPath)); } catch (FileNotFoundException e) { } long before = System.currentTimeMillis(); List<SeriesIdItem> seriesIdItems = readReadmeSeriesId(); log.info("readReadmeSeriesId elapsed=" + (System.currentTimeMillis() - before)); before = System.currentTimeMillis(); List<FredItem> fredItems = createFredItems(seriesIdItems); log.info("createfredItems elapsed=" + (System.currentTimeMillis() - before)); before = System.currentTimeMillis(); runCreateTableTsvs(fredItems); log.info("createTableTsvs elapsed=" + (System.currentTimeMillis() - before)); before = System.currentTimeMillis(); new DistinctCategories(properties, distinctCategoryItems, outputPath).createReportAndQlikViewSqlScripts(); log.info("createReportAndQlikViewSqlScripts elapsed=" + (System.currentTimeMillis() - before)); }
From source file:com.vmware.photon.controller.common.dcp.helpers.dcp.MultiHostEnvironment.java
/** * Stop the DCP host.//from w ww.java 2 s. com * * @throws Throwable */ public void stop() throws Throwable { this.dumpHosts(); for (H host : hosts) { host.stop(); File sandbox = new File(host.getStorageSandbox()); FileUtils.forceDelete(sandbox); } }
From source file:hoot.services.controllers.ingest.FileUploadResourceTest.java
@Test @Category(UnitTest.class) public void TestBuildNativeRequestFgdbOgr() throws Exception { String jobId = "test-id-123"; String wkdirpath = homeFolder + "/upload/" + jobId; File workingDir = new File(wkdirpath); FileUtils.forceMkdir(workingDir);// w ww.j a va2s . c o m org.junit.Assert.assertTrue(workingDir.exists()); File srcFile = new File(homeFolder + "/test-files/service/FileUploadResourceTest/fgdb_ogr.zip"); File destFile = new File(wkdirpath + "/fgdb_ogr.zip"); FileUtils.copyFile(srcFile, destFile); org.junit.Assert.assertTrue(destFile.exists()); FileUploadResource res = new FileUploadResource(); // Let's test zip JSONArray results = new JSONArray(); JSONObject zipStat = new JSONObject(); res._buildNativeRequest(jobId, "fgdb_ogr", "zip", "fgdb_ogr.zip", results, zipStat); org.junit.Assert.assertTrue(results.size() == 2); for (Object oRes : results) { JSONObject cnt = (JSONObject) oRes; if (cnt.get("type").toString().equals("FGDB_ZIP")) { org.junit.Assert.assertTrue(cnt.get("name").toString().equals("fgdb_ogr/DcGisRoads.gdb")); } else if (cnt.get("type").toString().equals("OGR_ZIP")) { org.junit.Assert .assertTrue(cnt.get("name").toString().equals("fgdb_ogr/jakarta_raya_coastline.shp")); } } FileUtils.forceDelete(workingDir); }
From source file:io.druid.indexing.kafka.test.TestBroker.java
@Override public void close() throws IOException { if (server != null) { server.shutdown();// w w w . ja v a 2 s.c o m server.awaitShutdown(); } if (directoryCleanup) { FileUtils.forceDelete(directory); } }
From source file:com.uwsoft.editor.proxy.SceneDataManager.java
private void deleteScene(String sceneName) { ProjectManager projectManager = facade.retrieveProxy(ProjectManager.NAME); ArrayList<SceneVO> scenes = projectManager.currentProjectInfoVO.scenes; SceneVO sceneToDelete = null;//www. j a va 2s.co m for (SceneVO scene : scenes) { if (scene.sceneName.equals(sceneName)) { sceneToDelete = scene; break; } } if (sceneToDelete != null) { scenes.remove(sceneToDelete); } projectManager.currentProjectInfoVO.scenes = scenes; String projPath = projectManager.getCurrentProjectPath(); try { FileUtils.writeStringToFile(new File(projPath + "/project.dt"), projectManager.currentProjectInfoVO.constructJsonString(), "utf-8"); FileUtils.forceDelete(new File(projPath + "/scenes/" + sceneName + ".dt")); } catch (IOException e) { e.printStackTrace(); } }
From source file:de.blizzy.backup.database.Database.java
public void close() { if (conn != null) { try {/*from w w w .ja v a 2 s.c om*/ conn.close(); } catch (SQLException e) { // ignore } finally { conn = null; factory = null; } if (heavyDuty) { try { copyFolder(folder, realFolder, false); FileUtils.forceDelete(folder); } catch (IOException e) { BackupPlugin.getDefault().logError("error while closing database", e); //$NON-NLS-1$ } finally { folder = realFolder; } } } }