org.eclipse.jgit.util.FileUtils.createNewFile()方法的使用及代码示例

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

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

FileUtils.createNewFile介绍

[英]Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist. The check for the existence of the file and the creation of the file if it does not exist are a single operation that is atomic with respect to all other filesystem activities that might affect the file.

Note: this method should not be used for file-locking, as the resulting protocol cannot be made to work reliably. The java.nio.channels.FileLock facility should be used instead.
[中]当且仅当具有此名称的文件尚不存在时,以原子方式创建一个以此抽象路径名命名的新空文件。对于可能影响文件的所有其他文件系统活动而言,检查文件是否存在和创建文件(如果不存在)是一个原子操作。
注意:此方法不应用于文件锁定,因为生成的协议无法可靠地工作。爪哇。尼奥。频道。应改用文件锁功能。

代码示例

代码示例来源:origin: org.eclipse.jgit/org.eclipse.jgit

private File getFile(String path, boolean create)
    throws PatchApplyException {
  File f = new File(getRepository().getWorkTree(), path);
  if (create)
    try {
      File parent = f.getParentFile();
      FileUtils.mkdirs(parent, true);
      FileUtils.createNewFile(f);
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().createNewFileFailed, f), e);
    }
  return f;
}

代码示例来源:origin: berlam/github-bucket

private File getFile(String path, boolean create)
    throws PatchApplyException {
  File f = new File(getRepository().getWorkTree(), path);
  if (create)
    try {
      File parent = f.getParentFile();
      FileUtils.mkdirs(parent, true);
      FileUtils.createNewFile(f);
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().createNewFileFailed, f), e);
    }
  return f;
}

代码示例来源:origin: sonia.jgit/org.eclipse.jgit

private File getFile(String path, boolean create)
    throws PatchApplyException {
  File f = new File(getRepository().getWorkTree(), path);
  if (create)
    try {
      File parent = f.getParentFile();
      FileUtils.mkdirs(parent, true);
      FileUtils.createNewFile(f);
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().createNewFileFailed, f), e);
    }
  return f;
}

代码示例来源:origin: org.eclipse.egit/ui

try {
  if (!file.exists())
    FileUtils.createNewFile(file);
  out = new FileOutputStream(file);
  out.write(getContent());

代码示例来源:origin: external.atlassian.jgitflow/jgit-flow-core

FileUtils.createNewFile(mergeBase);
FileHelper.writeStringToFile(gfConfig.getDevelop(), mergeBase);
reporter.endCommand();

代码示例来源:origin: io.ultreia.java4all.jgitflow/jgitflow-core

FileUtils.createNewFile(mergeBase);
FileHelper.writeStringToFile(gfConfig.getDevelop(), mergeBase);
reporter.endCommand();

代码示例来源:origin: com.atlassian.jgitflow/jgit-flow-core

FileUtils.createNewFile(mergeBase);
FileHelper.writeStringToFile(gfConfig.getDevelop(), mergeBase);
reporter.endCommand();

相关文章