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

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

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

FileUtils.forceDelete介绍

[英]Delete a file. If file is directory delete it and all sub-directories.
[中]删除一个文件。如果文件是目录,则删除它和所有子目录。

代码示例

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

/**
 * Delete a file. If file is directory delete it and all sub-directories.
 *
 * @param file the file path
 * @throws IOException if any
 */
public static void forceDelete( final String file )
  throws IOException
{
  forceDelete( new File( file ) );
}

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

forceDelete( file );

代码示例来源:origin: MovingBlocks/Terasology

@Before
public void setUp() throws IOException {
  FileUtils.forceDelete(new File(TMP_FOLDER.toUri()));
  Files.createDirectories(TMP_FOLDER);
}

代码示例来源:origin: apache/usergrid

FileUtils.forceDelete( targetFolder + existing.get( 0 ) );

代码示例来源:origin: MovingBlocks/Terasology

@AfterClass
public static void clean() throws IOException {
  FileUtils.forceDelete(new File(Paths.get("out", "test", "engine-tests", "tmp").toUri()));
}

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

/**
 * Delete a file. If file is directory delete it and all sub-directories.
 */
public static void forceDelete( final String file )
  throws IOException
{
  forceDelete( new File( file ) );
}

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

/**
 * Cleans specified cache directory. If present, Locker.LOCK_FILE will not be deleted.
 */
protected void cleanCacheDirectory( File dir )
  throws IOException
{
  File[] members = dir.listFiles();
  if ( members == null )
  {
    return;
  }
  for ( File member : members )
  {
    if ( !Locker.LOCK_FILE.equals( member.getName() ) )
    {
      FileUtils.forceDelete( member );
    }
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-api

public void delete()
  throws IOException
{
  FileUtils.forceDelete( getFile() );
}

代码示例来源:origin: org.sonatype.nexus/nexus-api

public void close()
    throws IOException
  {
    super.close();
    FileUtils.forceDelete( file );
  }
}

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

/**
 * Cleans specified cache directory. If present, Locker.LOCK_FILE will not be deleted.
 */
protected void cleanCacheDirectory( File dir )
  throws IOException
{
  File[] members = dir.listFiles();
  if ( members == null )
  {
    return;
  }
  for ( File member : members )
  {
    if ( !Locker.LOCK_FILE.equals( member.getName() ) )
    {
      FileUtils.forceDelete( member );
    }
  }
}

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

/**
 * Cleans specified cache directory. If present, Locker.LOCK_FILE will not be deleted.
 */
protected void cleanCacheDirectory( File dir )
  throws IOException
{
  File[] members = dir.listFiles();
  if ( members == null )
  {
    return;
  }
  for ( File member : members )
  {
    if ( !Locker.LOCK_FILE.equals( member.getName() ) )
    {
      FileUtils.forceDelete( member );
    }
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-indexer

/**
 * Cleans specified cache directory. If present, Locker.LOCK_FILE will not
 * be deleted.
 */
protected void cleanCacheDirectory( File dir )
  throws IOException
{
  File[] members = dir.listFiles();
  if ( members == null )
  {
    return;
  }
  for ( File member : members )
  {
    if ( !Locker.LOCK_FILE.equals( member.getName() ) )
    {
      FileUtils.forceDelete( member );
    }
  }
}

代码示例来源:origin: org.sonatype.nexus/nexus-indexer-lucene-app

private void purgeCurrentIndex( IndexingContext context )
  throws IOException
{
  context.purge();
  File repoDir = context.getRepository();
  if ( repoDir != null && repoDir.isDirectory() )
  {
    File indexDir = new File( repoDir, ".index" );
    FileUtils.forceDelete( indexDir );
  }
}

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

public void execute()
    throws MojoExecutionException, MojoFailureException
  {
    File outFile = project.getFile();
    File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" );

    if ( backupFile.exists() )
    {
      getLog().info( "Accepting all changes to " + outFile );
      try
      {
        FileUtils.forceDelete( backupFile );
      }
      catch ( IOException e )
      {
        throw new MojoExecutionException( e.getMessage(), e );
      }
    }
  }
}

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

public void execute()
    throws MojoExecutionException, MojoFailureException
  {
    File outFile = project.getFile();
    File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" );

    if ( backupFile.exists() )
    {
      getLog().info( "Accepting all changes to " + outFile );
      try
      {
        FileUtils.forceDelete( backupFile );
      }
      catch ( IOException e )
      {
        throw new MojoExecutionException( e.getMessage(), e );
      }
    }
  }
}

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

public void execute()
    throws MojoExecutionException, MojoFailureException
  {
    File outFile = project.getFile();
    File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" );

    if ( backupFile.exists() )
    {
      getLog().info( "Restoring " + outFile + " from " + backupFile );
      try
      {
        FileUtils.copyFile( backupFile, outFile );
        FileUtils.forceDelete( backupFile );
      }
      catch ( IOException e )
      {
        throw new MojoExecutionException( e.getMessage(), e );
      }
    }
  }
}

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

public void execute()
    throws MojoExecutionException, MojoFailureException
  {
    File outFile = project.getFile();
    File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" );

    if ( backupFile.exists() )
    {
      getLog().info( "Restoring " + outFile + " from " + backupFile );
      try
      {
        FileUtils.copyFile( backupFile, outFile );
        FileUtils.forceDelete( backupFile );
      }
      catch ( IOException e )
      {
        throw new MojoExecutionException( e.getMessage(), e );
      }
    }
  }
}

代码示例来源:origin: STAMP-project/dspot

private static void printJavaFileAndDeleteClassFile(DSpotCompiler compiler, CtType classTest) {
    try {
      DSpotUtils.printCtTypeToGivenDirectory(classTest, compiler.getSourceOutputDirectory());
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
    String pathToDotClass =
        compiler.getBinaryOutputDirectory().getAbsolutePath() + "/"
            + classTest.getQualifiedName().replaceAll("\\.", "/") + ".class";
    try {
      forceDelete(pathToDotClass);
    } catch (IOException ignored) {
      LOGGER.warn("An exception has been thrown when trying to delete old .class file {}, continue...", pathToDotClass);
    }
  }
}

代码示例来源:origin: org.sonatype.maven.archetype/archetype-common

private void processPomWithMerge(Context context, File pom, String moduleOffset) throws Exception {
  log.debug("Processing pom " + pom + " with merge");
  File temporaryPom=getTemporaryFile(pom);
  processTemplate(temporaryPom, context, Constants.ARCHETYPE_RESOURCES + getOffsetSeparator(moduleOffset) + Constants.ARCHETYPE_POM, getEncoding(null), true);
  pomManager.mergePoms(pom, temporaryPom);
  // getTemporaryFile sets deleteOnExit. Lets try to delete and then make sure deleteOnExit is
  // still set. Windows has issues deleting files with certain JDKs.
  try {
    FileUtils.forceDelete(temporaryPom);
  }
  catch (IOException e) {
    temporaryPom.deleteOnExit();
  }
}

代码示例来源:origin: org.sonatype.buup/buup-runtime

public void commit()
  throws IOException
{
  switch ( getOperation() )
  {
    case WRITE:
    case OVERWRITE:
    case EDIT:
      FileUtils.copyFile( getOperatedFile(), getOriginalFile() );
      break;
    case DELETE:
      FileUtils.forceDelete( getOriginalFile() );
      break;
    default: // humm?
  }
}

相关文章