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

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

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

FileUtils.fileDelete介绍

[英]Deletes a file.
[中]删除一个文件。

代码示例

代码示例来源:origin: org.apache.maven.plugins/maven-idea-plugin

private void deleteFile( File file )
  {
    if ( file.exists() )
    {
      if ( !file.isDirectory() )
      {
        FileUtils.fileDelete( file.getAbsolutePath() );
      }
    }
  }
}

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

@Override
 public void unpackNar(final File unpackDir, final ArchiverManager archiverManager, final File file, final String os,
   final String linkerName, final AOL defaultAOL) throws MojoExecutionException, MojoFailureException {
  final File flagFile = new File(unpackDir, FileUtils.basename(file.getPath(), "." + NarConstants.NAR_EXTENSION)
    + ".flag");

  boolean process = false;
  if (!unpackDir.exists()) {
   unpackDir.mkdirs();
   process = true;
  } else if (!flagFile.exists()) {
   process = true;
  } else if (file.lastModified() > flagFile.lastModified()) {
   process = true;
  }

  if (process) {
   try {
    unpackNarAndProcess(archiverManager, file, unpackDir, os, linkerName, defaultAOL);
    FileUtils.fileDelete(flagFile.getPath());
    FileUtils.fileWrite(flagFile.getPath(), "");
   } catch (final IOException e) {
    throw new MojoFailureException("Cannot create flag file: " + flagFile.getPath(), e);
   }
  }
 }
}

代码示例来源:origin: com.paypal.butterfly/butterfly-utilities

@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
  File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
  File fileTo = getFileTo(transformedAppFolder, transformationContext);
  TOExecutionResult result = null;
  // TODO
  // Check if it is really a file and if it exists!
  try {
    String details = String.format("File '%s' has been moved to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo));
    FileUtils.copyFileToDirectory(fileFrom, fileTo);
    FileUtils.fileDelete(fileFrom.getAbsolutePath());
    result = TOExecutionResult.success(this, details);
  } catch (IOException e) {
    result = TOExecutionResult.error(this, e);
  }
  return result;
}

相关文章