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


Java FileUtils.deleteDirectory方法代码示例

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


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

示例1: validateOsxDirectoryWatcherPreExistingSubdir

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void validateOsxDirectoryWatcherPreExistingSubdir() throws Exception {
  
  Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("mac"));
  File directory = new File(new File("").getAbsolutePath(), "target/directory");
  FileUtils.deleteDirectory(directory);
  directory.mkdirs();
  
  //make a dir before the watch is started
  File zupDir = Paths.get(directory.toString(), "zup").toFile();
  zupDir.mkdir();
  
  assertTrue(zupDir.exists());
  
  //prep a new file for the watched directory
  File fileInZupDir = new File(zupDir, "fileInZupDir.txt");
  assertFalse(fileInZupDir.exists());
  
  //write it to the zup subdirectory of the watched directory
  Files.write(fileInZupDir.toPath(), "some data".getBytes());
  assertTrue(fileInZupDir.exists());
  
  //files are written and done, now start the watcher
  runWatcher(directory.toPath(), new WatchablePath(directory.toPath()), new MacOSXListeningWatchService(), true);
  
}
 
开发者ID:takari,项目名称:directory-watcher,代码行数:27,代码来源:JdkDirectoryWatcherTest.java

示例2: getThreadFolder

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private File getThreadFolder() throws MojoFailureException {
    if(threadFolder != null) {
        return threadFolder;
    }

    threadFolder = new File(project.getBuild().getDirectory(), "cucumber/threads");

    try {
        FileUtils.deleteDirectory(threadFolder);
    } catch (IOException e) {
        throw new MojoFailureException(
                format("Cannot delete thread folder: %s", threadFolder
                .getAbsolutePath()), e);
    }

    if(!threadFolder.mkdirs()) {
        throw new MojoFailureException(
                format("Could not create thread folder at: %s", threadFolder
                        .getAbsolutePath()));

    }

    return threadFolder;
}
 
开发者ID:eu-evops,项目名称:cucumber-runner-maven-plugin,代码行数:25,代码来源:Run.java

示例3: execute

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void execute() throws MojoFailureException {
    if (new SkipUtil().isSkip(this.getClass())) {
        return;
    }

    if (wipeoutWorkspace)
    {
        getLog().info("Deleting the workspace directory: " + workspace);
        if (workspace.exists()) {
            try {
                FileUtils.deleteDirectory(workspace);
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }

    }
    else
    {
        getLog().info("'wipeoutWorkspace' configuration property set to false - workspace will not be deleted");
    }
}
 
开发者ID:bretthshelley,项目名称:Maven-IIB9-Plug-In,代码行数:24,代码来源:CleanBarBuildWorkspaceMojo.java

示例4: execute

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void execute() throws MojoExecutionException, MojoFailureException {
    // mvn
    // org.apache.maven.plugins:maven-dependency-plugin:2.1:copy-dependencies
    // -DoutputDirectory=${project.build.directory}/iib/classloader

    executeMojo(plugin(groupId("org.apache.maven.plugins"), artifactId("maven-dependency-plugin"), version("2.8")), goal("copy-dependencies"), configuration(element(name("outputDirectory"),
            project.getBuild().getDirectory() + "/dependency"), element(name("includeScope"), "runtime"), element(name("includeTypes"), "jar")),
            executionEnvironment(project, session, buildPluginManager));

    // delete the dependency-maven-plugin-markers directory
    try {
        FileUtils.deleteDirectory(new File(project.getBuild().getDirectory(), "dependency-maven-plugin-markers"));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}
 
开发者ID:bretthshelley,项目名称:Maven-IIB9-Plug-In,代码行数:19,代码来源:PrepareIibParPackagingMojo.java

示例5: deleteDirectoryOfPreviousRunIfExist

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
protected void deleteDirectoryOfPreviousRunIfExist( File directoryOfPreviousRun )
    throws MojoExecutionException
{

    if ( directoryOfPreviousRun.exists() )
    {
        try
        {
            FileUtils.deleteDirectory( directoryOfPreviousRun );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( "Failure while deleting " + directoryOfPreviousRun.getAbsolutePath(),
                                              e );
        }
    }
}
 
开发者ID:khmarbaise,项目名称:multienv-maven-plugin,代码行数:18,代码来源:AbstractMultiEnvMojo.java

示例6: removeDirectory

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void removeDirectory( File dir )
        throws MojoExecutionException
{
    if ( dir != null )
    {
        if ( dir.exists() && dir.isDirectory() )
        {
            getLogger().debug( "Deleting directory " + dir.getAbsolutePath() );
            try
            {
                FileUtils.deleteDirectory( dir );
            }
            catch ( IOException e )
            {
                throw new MojoExecutionException( "Could not delete directory: " + dir, e );
            }
        }
    }
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:23,代码来源:DefaultIOUtil.java

示例7: execute

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void execute() throws MojoExecutionException, MojoFailureException
{
    if (skip)
    {
        getLog().info("Skipping cassandra: cassandra.skip==true");
        return;
    }
    try
    {
        getLog().info("Deleting " + cassandraDir.getAbsolutePath());
        FileUtils.deleteDirectory(cassandraDir);
    } catch (IOException e)
    {
        if (failOnError)
        {
            throw new MojoFailureException(e.getLocalizedMessage(), e);
        }
        getLog().warn("Failed to delete " + cassandraDir.getAbsolutePath(), e);
    }
}
 
开发者ID:mojohaus,项目名称:cassandra-maven-plugin,代码行数:24,代码来源:DeleteCassandraMojo.java

示例8: createDirectory

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * Convenience method to successfully create a directory - or throw an exception if failing to create it.
 *
 * @param aDirectory        The directory to create.
 * @param cleanBeforeCreate if {@code true}, the directory and all its content will be deleted before being
 *                          re-created. This will ensure that the created directory is really clean.
 * @throws MojoExecutionException if the aDirectory could not be created (and/or cleaned).
 */
public static void createDirectory(final File aDirectory, final boolean cleanBeforeCreate)
        throws MojoExecutionException {

    // Check sanity
    Validate.notNull(aDirectory, "aDirectory");
    validateFileOrDirectoryName(aDirectory);

    // Clean an existing directory?
    if (cleanBeforeCreate) {
        try {
            FileUtils.deleteDirectory(aDirectory);
        } catch (IOException e) {
            throw new MojoExecutionException("Could not clean directory [" + getCanonicalPath(aDirectory) + "]", e);
        }
    }

    // Now, make the required directory, if it does not already exist as a directory.
    final boolean existsAsFile = aDirectory.exists() && aDirectory.isFile();
    if (existsAsFile) {
        throw new MojoExecutionException("[" + getCanonicalPath(aDirectory) + "] exists and is a file. "
                + "Cannot make directory");
    } else if (!aDirectory.exists() && !aDirectory.mkdirs()) {
        throw new MojoExecutionException("Could not create directory [" + getCanonicalPath(aDirectory) + "]");
    }
}
 
开发者ID:mojohaus,项目名称:jaxb2-maven-plugin,代码行数:34,代码来源:FileSystemUtilities.java

示例9: generateConfdArtefacts

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public static void generateConfdArtefacts(
    PrepareContext context,
    List<TemplateConfig> templates,
    boolean forceDestToLocalFileSystemType,
    Log log
) throws IOException {

    File workingDirectory = context.getWorkingDirectory();

    File templatesDirectory = new File(workingDirectory, TEMPLATES_DIRECTORY);
    File tomlDirectory = new File(workingDirectory, CONF_D_DIRECTORY);

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

    FileUtils.mkdir(templatesDirectory.getAbsolutePath());
    FileUtils.mkdir(tomlDirectory.getAbsolutePath());
    for (TemplateConfig tc : templates) {
        String tomlBaseName = FileUtils.basename(tc.getSrc().getAbsolutePath()) + TOML_FILE_EXT;
        File tomlFile = new File(tomlDirectory, tomlBaseName);
        writeToml(tomlFile, tc, forceDestToLocalFileSystemType);
        FileUtils.copyFileToDirectory(tc.getSrc(), templatesDirectory);
        warnAboutKeysExcludedByNamespace(tc, context, log);
    }
}
 
开发者ID:nodevops,项目名称:confd-maven-plugin,代码行数:27,代码来源:WorkingDirectoryUtil.java

示例10: removeDirectory

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
protected void removeDirectory( File directory )
    throws MojoExecutionException
{
    if ( directory.exists() )
    {
        try
        {
            this.getLog().info( "Removing " + directory );
            FileUtils.deleteDirectory( directory );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( e.getMessage(), e );
        }
    }
}
 
开发者ID:mojohaus,项目名称:appassembler,代码行数:17,代码来源:AbstractAppAssemblerMojo.java

示例11: cleanLocalDir

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void cleanLocalDir(String dir) {
    try {
        FileUtils.deleteDirectory(new File(dir));
    } catch (IOException e) {
        logger.error("Failed cleaning local directory " + dir, e);
    }
}
 
开发者ID:razreg,项目名称:ubongo,代码行数:8,代码来源:RequestHandler.java

示例12: tearDown

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@After
@Override
public void tearDown()
    throws Exception
{
    FileUtils.deleteDirectory( repoDir );

    assertFalse( repoDir.exists() );

    super.tearDown();
}
 
开发者ID:ruikom,项目名称:apache-archiva,代码行数:12,代码来源:ArchivaRepositoryScanningTaskExecutorAbstractTest.java

示例13: deleteStoreFolder

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void deleteStoreFolder() throws MojoFailureException {
  try {
    final File goStoreFolder = new File(getStoreFolder());
    if (goStoreFolder.isDirectory()) {
      getLog().info("Deleting the Store Folder : " + goStoreFolder);
      FileUtils.deleteDirectory(goStoreFolder);
    } else {
      getLog().info("The Store Folder does not found : " + goStoreFolder);
    }
  } catch (IOException ex) {
    throw new MojoFailureException("Can't delete the Store Folder", ex);
  }
}
 
开发者ID:raydac,项目名称:mvn-golang,代码行数:14,代码来源:GolangCleanMojo.java

示例14: validateOsxDirectoryWatcher

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void validateOsxDirectoryWatcher() throws Exception {
  
  Assume.assumeTrue(System.getProperty("os.name").toLowerCase().contains("mac"));
  File directory = new File(new File("").getAbsolutePath(), "target/directory");
  FileUtils.deleteDirectory(directory);
  directory.mkdirs();
  runWatcher(directory.toPath(), new WatchablePath(directory.toPath()), new MacOSXListeningWatchService(), true);
}
 
开发者ID:takari,项目名称:directory-watcher,代码行数:10,代码来源:JdkDirectoryWatcherTest.java

示例15: validateJdkDirectoryWatcher

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Test
public void validateJdkDirectoryWatcher() throws Exception {
  Assume.assumeFalse(System.getProperty("os.name").toLowerCase().contains("mac"));
  File directory = new File(new File("").getAbsolutePath(), "target/directory");
  FileUtils.deleteDirectory(directory);
  directory.mkdirs();
  runWatcher(directory.toPath(), directory.toPath(), FileSystems.getDefault().newWatchService(), false);
}
 
开发者ID:takari,项目名称:directory-watcher,代码行数:9,代码来源:JdkDirectoryWatcherTest.java


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