当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.deleteDirectory方法代码示例

本文整理汇总了Java中org.apache.commons.io.FileUtils.deleteDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.deleteDirectory方法的具体用法?Java FileUtils.deleteDirectory怎么用?Java FileUtils.deleteDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.io.FileUtils的用法示例。


在下文中一共展示了FileUtils.deleteDirectory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: delete

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public boolean delete(Path path, boolean b) throws IOException {
  path = localize(path);
  File file = new File(path.toString());
  if (b) {
    if (file.isDirectory()) {
      FileUtils.deleteDirectory(file);
    } else {
      file.delete();
    }
  } else if (file.isDirectory()) {
    throw new IOException("Cannot delete directory");
  }
  file.delete();
  return true;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:17,代码来源:LocalSyncableFileSystem.java

示例2: load

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 从指定的git仓库地址(目前仅支持http和https)和文件名获取资源,通过UsernameCredential支持鉴权
 * @return 资源的字符串
 * @throws Exception 资源不存在或网络不通
 */
@Override
public String load() throws Exception {
    //本地临时目录,用户存放clone的代码
    String tempDirPath = localPath + "/iaac.aliyun.tmp_" + new Date().getTime();
    File tempDir = new File(tempDirPath);
    tempDir.mkdirs();
    String result = null;
    try {
        CloneCommand clone = Git.cloneRepository();
        clone.setURI(url);
        clone.setBranch(this.branch);
        clone.setDirectory(tempDir);

        //设置鉴权
        if (this.credential != null) {
            UsernamePasswordCredentialsProvider usernamePasswordCredentialsProvider = new
                    UsernamePasswordCredentialsProvider(this.credential.getUsername(), this.credential.getPassword());
            //git仓库地址
            clone.setCredentialsProvider(usernamePasswordCredentialsProvider);
        }
        //执行clone
        Git git = clone.call();
        //从本地路径中获取指定的文件
        File file = new File(tempDir.getAbsolutePath() + "/" + this.fileName);
        //返回文件的字符串
        result = FileUtils.readFileToString(file, "utf-8");
    } catch (Exception e) {
        throw e;
    } finally {
        //清除本地的git临时目录
        FileUtils.deleteDirectory(tempDir);
    }
    return result;
}
 
开发者ID:peterchen82,项目名称:iaac4j.aliyun,代码行数:40,代码来源:GitLoader.java

示例3: startMiniCluster

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@BeforeClass
public static void startMiniCluster() throws Exception {
  File targetDir = new File(System.getProperty("user.dir"), "target");
  File macDir = new File(targetDir, DelimitedIngestMiniClusterTest.class.getSimpleName() + "_cluster");
  if (macDir.exists()) {
    FileUtils.deleteDirectory(macDir);
  }
  MiniAccumuloConfigImpl config = new MiniAccumuloConfigImpl(macDir, ROOT_PASSWORD);
  config.setNumTservers(1);
  config.setInstanceName(INSTANCE_NAME);
  config.setSiteConfig(Collections.singletonMap("fs.file.impl", RawLocalFileSystem.class.getName()));
  config.useMiniDFS(true);
  MAC = new MiniAccumuloClusterImpl(config);
  MAC.start();
  FS = FileSystem.get(MAC.getMiniDfs().getConfiguration(0));

  ARGS = new DelimitedIngestArguments();
  ARGS.setUsername("root");
  ARGS.setPassword(ROOT_PASSWORD);
  ARGS.setInstanceName(INSTANCE_NAME);
  ARGS.setZooKeepers(MAC.getZooKeepers());
  ARGS.setConfiguration(MAC.getMiniDfs().getConfiguration(0));
}
 
开发者ID:joshelser,项目名称:accumulo-delimited-ingest,代码行数:24,代码来源:DelimitedIngestMiniClusterTest.java

示例4: cleanAirsonicHomeForTest

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * Cleans the AIRSONIC_HOME directory used for tests.
 *
 * @throws IOException
   */
public static void cleanAirsonicHomeForTest() throws IOException {

  File airsonicHomeDir = new File(airsonicHomePathForTest());
  if (airsonicHomeDir.exists() && airsonicHomeDir.isDirectory()) {
    System.out.println("Delete airsonic home (ie. "+airsonicHomeDir.getAbsolutePath()+").");
    try {
      FileUtils.deleteDirectory(airsonicHomeDir);
    } catch (IOException e) {
      System.out.println("Error while deleting airsonic home.");
      e.printStackTrace();
      throw e;
    }
  }

}
 
开发者ID:airsonic,项目名称:airsonic,代码行数:21,代码来源:TestCaseUtils.java

示例5: cleanup

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@After
public void cleanup() throws IOException
{
    btreeNoTransactions.close();
    btreeWithTransactions.close();

    recordManagerNoTxn.close();
    recordManagerTxn.close();
    
    assertTrue( recordManagerNoTxn.isContextOk() );
    assertTrue( recordManagerTxn.isContextOk() );

    if ( dataDirNoTxn.exists() )
    {
        FileUtils.deleteDirectory( dataDirNoTxn );
    }

    if ( dataDirWithTxn.exists() )
    {
        FileUtils.deleteDirectory( dataDirWithTxn );
    }
}
 
开发者ID:apache,项目名称:directory-mavibot,代码行数:23,代码来源:PersistedBTreeTransactionTest.java

示例6: deleteDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * 
 * @param path {@link File}
 * @return boolean
 */
public static boolean deleteDirectory(Path path) {
    if (Files.isDirectory(path)) {
        try {
            FileUtils.deleteDirectory(path.toFile());
            return true;
        } catch (IOException e) {
            logger.error(e.getMessage());
        }
    }

    return false;
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:18,代码来源:Utils.java

示例7: aggressiveClearingHandlesEdit

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/** @see <a href="https://github.com/JakeWharton/DiskLruCache/issues/2">Issue #2</a> */
@Test public void aggressiveClearingHandlesEdit() throws Exception {
  set("a", "a", "a");
  DiskLruCache.Editor a = cache.get("a").edit();
  FileUtils.deleteDirectory(cacheDir);
  a.set(1, "a2");
  a.commit();
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:9,代码来源:DiskLruCacheTest.java

示例8: freeResources

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@After
public void freeResources() {
	gitAccess.close();
	File dirToDelete = new File(LOCAL_TEST_REPOSITPRY);
	try {
		FileUtils.deleteDirectory(dirToDelete);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:11,代码来源:GItAccessStagedFilesTest.java

示例9: moveDirectory

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
public static void moveDirectory(String source, String destination) {
    File sourceFile = new File(source);
    File destFile = new File(destination);
    try {
        if (sourceFile.exists()) {
            FileUtils.copyDirectoryToDirectory(sourceFile, destFile.getParentFile());
            FileUtils.deleteDirectory(sourceFile);
        }
    } catch (IOException ex) {
        Logger.getLogger(FileOptions.class.getName()).log(Level.SEVERE, null, ex);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:13,代码来源:FileOptions.java

示例10: testScreenShotIOE

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Test
public void testScreenShotIOE() throws URISyntaxException, IOException {
	try {
		Mockito.when(mockDriver.getScreenshotAs(ArgumentMatchers.any(OutputType.class)))
				.thenReturn(new File(Thread.currentThread().getContextClassLoader().getResource("log4j2.json").toURI()).getParentFile());
		screenshot("test.png");
		Assert.assertFalse(new File(baseDir, "sc/test.png").exists());
	} finally {
		FileUtils.deleteDirectory(new File(baseDir, "sc"));
	}
}
 
开发者ID:ligoj,项目名称:bootstrap,代码行数:13,代码来源:TAbstractSeleniumTest.java

示例11: onExecuteCommand

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Override
public void onExecuteCommand(CommandSender sender, String[] args)
{
    try{

        FileUtils.deleteDirectory(new File("local/cache"));
        Files.createDirectories(Paths.get("local/cache/web_templates"));
        Files.createDirectories(Paths.get("local/cache/web_plugins"));

    }catch (Exception ex){
        ex.printStackTrace();
    }

    sender.sendMessage("The Cache was cleared!");
}
 
开发者ID:Dytanic,项目名称:CloudNet,代码行数:16,代码来源:CommandClearCache.java

示例12: cleanPodLogDirectories

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
/**
 * Cleans pod logs directories.
 *
 * <p>
 * In case of {@link IOException}, the exception is logged and ignored.
 * </p>
 */
public static void cleanPodLogDirectories() {
	final File podLogsDir = OpenshiftUtil.getPodLogsDir().toFile();
	log.info("action=clean-pod-logs status=START dir={}", podLogsDir.getAbsolutePath());
	try {
		if (podLogsDir.exists()) {
			FileUtils.deleteDirectory(podLogsDir);
		}
		podLogsDir.mkdirs();
		log.info("action=clean-pod-logs status=FINISH dir={}", podLogsDir.getAbsolutePath());
	} catch (IOException e) {
		log.error("action=clean-pod-logs status=ERROR dir={}", podLogsDir.getAbsolutePath(), e);
	}
}
 
开发者ID:xtf-cz,项目名称:xtf,代码行数:21,代码来源:LogCleaner.java

示例13: testBinWinUtilsNotAFile

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@Test
public void testBinWinUtilsNotAFile() throws Throwable {
  try {
    File bin = new File(methodDir, "bin");
    File winutils = new File(bin, WINUTILS_EXE);
    winutils.mkdirs();
    assertWinutilsResolveFailed(methodDir, E_NOT_EXECUTABLE_FILE);
  } finally {
    FileUtils.deleteDirectory(methodDir);
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:12,代码来源:TestShell.java

示例14: clear

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
private void clear() {
    boolean failed = false;

    TextDisplayerMod.getInstance().getLoader().getMessages().clear();
    try {
        FileUtils.deleteDirectory(TextDisplayerMod.getInstance().getLoader().getMainDir());
    } catch (IOException ex) {
        failed = true;
    }

    log(failed ? "Failed to clear all display messages" : "Removed all display messages!");
    displayPrevious(failed ? "Failed to clear messages!" : "&aSuccesfully removed all messages!");
}
 
开发者ID:boomboompower,项目名称:TextDisplayer,代码行数:14,代码来源:ClearGui.java

示例15: tearDown

import org.apache.commons.io.FileUtils; //导入方法依赖的package包/类
@After
public void tearDown() throws IOException {

    // Clear the TrailDB files/directories created for the tests.
    final File f = new File(this.path + ".tdb");
    if (f.exists() && !f.isDirectory()) {
        f.delete();
    }
    FileUtils.deleteDirectory(new File(this.path));
    this.db.close();
}
 
开发者ID:Sqooba,项目名称:traildb-java,代码行数:12,代码来源:TrailDBTest.java


注:本文中的org.apache.commons.io.FileUtils.deleteDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。