org.mule.runtime.core.api.util.FileUtils.deleteTree()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(163)

本文整理了Java中org.mule.runtime.core.api.util.FileUtils.deleteTree()方法的一些代码示例,展示了FileUtils.deleteTree()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.deleteTree()方法的具体详情如下:
包路径:org.mule.runtime.core.api.util.FileUtils
类名称:FileUtils
方法名:deleteTree

FileUtils.deleteTree介绍

[英]Delete a file tree recursively.
[中]递归删除文件树。

代码示例

代码示例来源:origin: mulesoft/mule

private void deleteFtpServerBaseDir() {
 FileUtils.deleteTree(baseDir);
}

代码示例来源:origin: mulesoft/mule

if (artifactDir.exists() && !deleteTree(artifactDir)) {
 throw new IOException("Cannot delete existing folder '" + artifactDir + "'");
 deleteTree(artifactDir);

代码示例来源:origin: mulesoft/mule

@After
public void cleanUp() {
 if (previousMuleHome != null) {
  setProperty(MULE_HOME_DIRECTORY_PROPERTY, previousMuleHome);
 }
 FileUtils.deleteTree(tempMuleHome.getRoot());
}

代码示例来源:origin: mulesoft/mule

@After
public void cleanUp() {
 if (previousMuleHome != null) {
  System.setProperty(MULE_HOME_DIRECTORY_PROPERTY, previousMuleHome);
 }
 FileUtils.deleteTree(tempMuleHome.getRoot());
}

代码示例来源:origin: mulesoft/mule

doWithoutFail(() -> application.stop());
doWithoutFail(() -> application.dispose());
doWithoutFail(() -> deleteTree(application.getLocation()));

代码示例来源:origin: mulesoft/mule

@AfterClass
public static void disposeContext() throws MuleException {
 try {
  if (muleContext != null && !(muleContext.isDisposed() || muleContext.isDisposing())) {
   try {
    muleContext.dispose();
   } catch (IllegalStateException e) {
    // Ignore
    LOGGER.warn(e + " : " + e.getMessage());
   }
   verifyAndStopSchedulers();
   MuleConfiguration configuration = muleContext.getConfiguration();
   if (configuration != null) {
    final String workingDir = configuration.getWorkingDirectory();
    // do not delete TM recovery object store, everything else is good to
    // go
    deleteTree(newFile(workingDir), IGNORED_DOT_MULE_DIRS);
   }
  }
  deleteTree(newFile("./ActiveMQ"));
 } finally {
  muleContext = null;
  clearLoggingConfig();
 }
}

代码示例来源:origin: mulesoft/mule

@Test
public void testDeleteTreeWithIgnoredDirectories() throws Exception {
 final String testDir = TEST_DIRECTORY + File.separator + "Test-deleting";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 File toBeDeleted1 = FileUtils.newFile(outputDir, "toBeDeleted1/");
 toBeDeleted1.mkdirs();
 File toBeDeleted2 = FileUtils.newFile(outputDir, "toBeDeleted2/");
 toBeDeleted2.mkdirs();
 File keepMeIntact = FileUtils.newFile(outputDir, "keepMeIntact/");
 keepMeIntact.mkdirs();
 FileUtils.deleteTree(outputDir, new String[] {"keepMeIntact"});
 assertTrue("Shouldn't have been deleted.", keepMeIntact.exists());
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

/**
 * Copies a given app archive with a given target name to the apps folder for deployment
 */
private void addExplodedArtifact(URL url, String artifactName, String configFileName, File destinationDir) throws Exception {
 ReentrantLock lock = deploymentService.getLock();
 lock.lock();
 try {
  File tempFolder = new File(muleHome, artifactName);
  FileUtils.unzip(new File(url.toURI()), tempFolder);
  // Under some platforms, file.lastModified is managed at second level, not milliseconds.
  // Need to update the config file lastModified ere to ensure that is different from previous value
  File configFile = new File(tempFolder, getConfigFilePathWithinArtifact(configFileName));
  if (configFile.exists()) {
   configFile.setLastModified(currentTimeMillis() + FILE_TIMESTAMP_PRECISION_MILLIS);
  }
  File appFolder = new File(destinationDir, artifactName);
  if (appFolder.exists()) {
   FileUtils.deleteTree(appFolder);
  }
  moveDirectory(tempFolder, appFolder);
 } finally {
  lock.unlock();
 }
}

代码示例来源:origin: mulesoft/mule

@After
public void tearDown() throws Exception {
 if (deploymentService != null) {
  deploymentService.stop();
 }
 if (serviceManager != null) {
  serviceManager.stop();
 }
 if (extensionModelLoaderManager != null) {
  extensionModelLoaderManager.stop();
 }
 FileUtils.deleteTree(muleHome);
 // this is a complex classloader setup and we can't reproduce standalone Mule 100%,
 // so trick the next test method into thinking it's the first run, otherwise
 // app resets CCL ref to null and breaks the next test
 Thread.currentThread().setContextClassLoader(ClassLoader.getSystemClassLoader());
 if (parallelDeployment) {
  System.clearProperty(PARALLEL_DEPLOYMENT_PROPERTY);
 }
}

代码示例来源:origin: mulesoft/mule

deleteTree(tempFolder);

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractResources() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-2";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String res = "META-INF/";
 FileUtils.extractResources(res, getClass(), outputDir, true);
 File result = FileUtils.newFile(testDir, res);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isDirectory());
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractResourceWithoutKeepingDirStructure() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-5";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String fileName = "MANIFEST.MF";
 String res = "META-INF/" + fileName;
 FileUtils.extractResources(res, getClass(), outputDir, false);
 File result = FileUtils.newFile(testDir, fileName);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isFile());
 assertTrue(result.length() > 0);
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractFileResources() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-4";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String res = "org/mule/runtime/core/api/util/";
 FileUtils.extractResources(res, FileUtils.class, outputDir, true);
 File result = FileUtils.newFile(testDir, res);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isDirectory());
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractFileResourcesWithoutKeepingDirStructure() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-8";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String fileName = "util/FileUtilsTestCase.class";
 String res = "org/mule/runtime/core/api/";
 FileUtils.extractResources(res, FileUtilsTestCase.class, outputDir, false);
 File result = FileUtils.newFile(testDir, fileName);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isFile());
 assertTrue(result.length() > 0);
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractResource() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-1";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  assertTrue("Failed to create output dirs.", outputDir.mkdirs());
 }
 String res = "META-INF/MANIFEST.MF";
 FileUtils.extractResources(res, getClass(), outputDir, true);
 File result = FileUtils.newFile(testDir, res);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isFile());
 assertTrue(result.length() > 0);
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractFileResource() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-3";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String res = "org/mule/runtime/core/api/util/FileUtils.class";
 FileUtils.extractResources(res, FileUtils.class, outputDir, true);
 File result = FileUtils.newFile(testDir, res);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isFile());
 assertTrue(result.length() > 0);
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractResourcesWithoutKeepingDirStructure() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-6";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String fileName = "util/FileUtilsTestCase.class";
 String res = "org/mule/runtime/core/api";
 FileUtils.extractResources(res, FileUtilsTestCase.class, outputDir, false);
 File result = FileUtils.newFile(testDir, fileName);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isFile());
 assertTrue(result.length() > 0);
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testDirectoryTools() throws Exception {
 File dir = FileUtils.openDirectory("src");
 assertNotNull(dir);
 assertTrue(dir.exists());
 assertTrue(dir.canRead());
 assertTrue(dir.isDirectory());
 dir = FileUtils.openDirectory("doesNotExist");
 assertNotNull(dir);
 assertTrue(dir.exists());
 assertTrue(dir.canRead());
 assertTrue(dir.isDirectory());
 FileUtils.deleteTree(dir);
}

代码示例来源:origin: mulesoft/mule

@Test
public void testExtractFileResourceWithoutKeepingDirStructure() throws Exception {
 String testDir = TEST_DIRECTORY + File.separator + "Test-7";
 File outputDir = FileUtils.newFile(testDir);
 if (!outputDir.exists()) {
  outputDir.mkdirs();
 }
 String fileName = "FileUtils.class";
 String res = "org/mule/runtime/core/api/util/" + fileName;
 FileUtils.extractResources(res, FileUtils.class, outputDir, false);
 File result = FileUtils.newFile(testDir, fileName);
 assertNotNull(result);
 assertTrue(result.exists());
 assertTrue(result.canRead());
 assertTrue(result.isFile());
 assertTrue(result.length() > 0);
 FileUtils.deleteTree(outputDir);
}

代码示例来源:origin: org.mule.runtime/mule-core

/**
 * Delete a file tree recursively.
 * 
 * @param dir dir to wipe out
 * @return false when the first unsuccessful attempt encountered
 */
public static boolean deleteTree(File dir) {
 return deleteTree(dir, null);
}

相关文章