org.codehaus.plexus.util.FileUtils.deleteDirectory()方法的使用及代码示例

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

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

FileUtils.deleteDirectory介绍

[英]Recursively delete a directory.
[中]递归地删除目录。

代码示例

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Recursively delete a directory.
 *
 * @param directory a directory
 * @throws IOException if any
 */
public static void deleteDirectory( final String directory )
  throws IOException
{
  deleteDirectory( new File( directory ) );
}

代码示例来源:origin: org.codehaus.plexus/plexus-utils

/**
 * Delete a file. If file is directory delete it and all sub-directories.
 *
 * @param file a file
 * @throws IOException if any
 */
public static void forceDelete( final File file )
  throws IOException
{
  if ( file.isDirectory() )
  {
    deleteDirectory( file );
  }
  else
  {
    /*
     * NOTE: Always try to delete the file even if it appears to be non-existent. This will ensure that a
     * symlink whose target does not exist is deleted, too.
     */
    boolean filePresent = file.getCanonicalFile().exists();
    if ( !deleteFile( file ) && filePresent )
    {
      final String message = "File " + file + " unable to be deleted.";
      throw new IOException( message );
    }
  }
}

代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness

/**
 * Creates new clean copy of test project directory structure. The copy is named after both the test being executed
 * and test project name, which allows the same test project can be used by multiple tests and by different
 * instances of the same parametrized tests.<br/>
 * TODO Provide alternative working directory naming for Windows, which still limits path names to ~250 charecters
 */
public File getBasedir( String project )
  throws IOException
{
  if ( name == null )
  {
    throw new IllegalStateException( getClass().getSimpleName()
      + " must be a test class field annotated with org.junit.Rule" );
  }
  File src = new File( projectsDir, project ).getCanonicalFile();
  Assert.assertTrue( "Test project directory does not exist: " + src.getPath(), src.isDirectory() );
  File basedir = new File( workDir, name + "_" + project ).getCanonicalFile();
  FileUtils.deleteDirectory( basedir );
  Assert.assertTrue( "Test project working directory created", basedir.mkdirs() );
  FileUtils.copyDirectoryStructure( src, basedir );
  return basedir;
}

代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-tools

public void run()
{
  try
  {
    FileUtils.deleteDirectory( tmpDir );
  }
  catch ( IOException e )
  {
    // it'll get cleaned up when the temp dir is purged next...
  }
}

代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-tools

public void run()
{
  try
  {
    FileUtils.deleteDirectory( tmpDir );
  }
  catch ( IOException e )
  {
    // it'll get cleaned up when the temp dir is purged next...
  }
}

代码示例来源:origin: org.apache.maven.indexer/indexer-core

public static void delete( File indexDir )
{
  try
  {
    FileUtils.deleteDirectory( indexDir );
  }
  catch ( IOException ex )
  {
    // ignore
  }
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-test

protected void deleteDirectory( File directory )
  throws IOException
{
  FileUtils.deleteDirectory( directory );
}

代码示例来源:origin: org.apache.maven.shared/maven-plugin-testing-tools

public void run()
{
  try
  {
    FileUtils.deleteDirectory( tmpDir );
  }
  catch ( IOException e )
  {
    // it'll get cleaned up when the temp dir is purged next...
  }
}

代码示例来源:origin: org.apache.maven.shared/maven-plugin-testing-tools

public void run()
{
  try
  {
    FileUtils.deleteDirectory( tmpDir );
  }
  catch ( IOException e )
  {
    // it'll get cleaned up when the temp dir is purged next...
  }
}

代码示例来源:origin: org.jboss.windup.org.apache.maven.indexer/indexer-core

public static void delete( File indexDir )
{
  try
  {
    FileUtils.deleteDirectory( indexDir );
  }
  catch ( IOException ex )
  {
    // ignore
  }
}

代码示例来源:origin: apache/maven-scm

protected void deleteDirectory( File directory )
  throws IOException
{
  FileUtils.deleteDirectory( directory );
}

代码示例来源:origin: locationtech/geowave

private static void cleanTempDir() {
 try {
  FileUtils.deleteDirectory(TEMP_DIR);
 } catch (final IOException e) {
  LOGGER.warn("Unable to delete temp cassandra directory", e);
 }
}

代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core

/**
 * Recursively delete a directory.
 */
public static void deleteDirectory( final String directory )
  throws IOException
{
  deleteDirectory( new File( directory ) );
}

代码示例来源:origin: org.apache.maven.scm/maven-scm-provider-gittest

public static void initRepo( File repository, File workingDirectory, File assertionDirectory )
  throws IOException
{
  initRepo( "src/test/repository/", repository, workingDirectory );
  FileUtils.deleteDirectory( assertionDirectory );
  Assert.assertTrue( assertionDirectory.mkdirs() );
}

代码示例来源:origin: org.codehaus.mojo/gwt-maven-plugin

private void clean( File output )
  {
    try
    {
      FileUtils.deleteDirectory( output );
    }
    catch ( IOException e )
    {
      getLog().warn( "Failed to delete directory " + output );
    }
  }
}

代码示例来源:origin: gwt-maven-plugin/gwt-maven-plugin

private void clean( File output )
  {
    try
    {
      FileUtils.deleteDirectory( output );
    }
    catch ( IOException e )
    {
      getLog().warn( "Failed to delete directory " + output );
    }
  }
}

代码示例来源:origin: apache/maven-scm

public static void initRepo( File repository, File workingDirectory, File assertionDirectory )
  throws IOException
{
  initRepo( "src/test/repository/", repository, workingDirectory );
  FileUtils.deleteDirectory( assertionDirectory );
  Assert.assertTrue( assertionDirectory.mkdirs() );
}

代码示例来源:origin: org.apache.maven.wagon/wagon-provider-test

public void testWagonGetFileList()
  throws Exception
{
  File dir = getRepositoryDirectory();
  FileUtils.deleteDirectory( dir );
  File f = new File( dir, "file-list" );
  f.mkdirs();
  super.testWagonGetFileList();
}

代码示例来源:origin: org.codehaus.modello/modello-test

protected void setUp()
  throws Exception
{
  super.setUp();
  FileUtils.deleteDirectory( getOutputClasses() );
  assertTrue( getOutputClasses().mkdirs() );
}

代码示例来源:origin: org.codehaus.modello/modello-test

protected void setUp()
  throws Exception
{
  super.setUp();
  FileUtils.deleteDirectory( getOutputDirectory() );
  assertTrue( getOutputDirectory().mkdirs() );
}

相关文章