org.apache.flink.util.FileUtils.cleanDirectoryInternal()方法的使用及代码示例

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

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

FileUtils.cleanDirectoryInternal介绍

暂无

代码示例

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

private static void deleteDirectoryInternal(File directory) throws IOException {
  if (directory.isDirectory()) {
    // directory exists and is a directory
    // empty the directory first
    try {
      cleanDirectoryInternal(directory);
    }
    catch (FileNotFoundException ignored) {
      // someone concurrently deleted the directory, nothing to do for us
      return;
    }
    // delete the directory. this fails if the directory is not empty, meaning
    // if new files got concurrently created. we want to fail then.
    // if someone else deleted the empty directory concurrently, we don't mind
    // the result is the same for us, after all
    Files.deleteIfExists(directory.toPath());
  }
  else if (directory.exists()) {
    // exists but is file, not directory
    // either an error from the caller, or concurrently a file got created
    throw new IOException(directory + " is not a directory");
  }
  // else: does not exist, which is okay (as if deleted)
}

代码示例来源:origin: com.alibaba.blink/flink-core

private static void deleteDirectoryInternal(File directory) throws IOException {
  if (directory.isDirectory()) {
    // directory exists and is a directory
    // empty the directory first
    try {
      cleanDirectoryInternal(directory);
    }
    catch (FileNotFoundException ignored) {
      // someone concurrently deleted the directory, nothing to do for us
      return;
    }
    // delete the directory. this fails if the directory is not empty, meaning
    // if new files got concurrently created. we want to fail then.
    // if someone else deleted the empty directory concurrently, we don't mind
    // the result is the same for us, after all
    Files.deleteIfExists(directory.toPath());
  }
  else if (directory.exists()) {
    // exists but is file, not directory
    // either an error from the caller, or concurrently a file got created
    throw new IOException(directory + " is not a directory");
  }
  // else: does not exist, which is okay (as if deleted)
}

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

private static void deleteDirectoryInternal(File directory) throws IOException {
  if (directory.isDirectory()) {
    // directory exists and is a directory
    // empty the directory first
    try {
      cleanDirectoryInternal(directory);
    }
    catch (FileNotFoundException ignored) {
      // someone concurrently deleted the directory, nothing to do for us
      return;
    }
    // delete the directory. this fails if the directory is not empty, meaning
    // if new files got concurrently created. we want to fail then.
    // if someone else deleted the empty directory concurrently, we don't mind
    // the result is the same for us, after all
    Files.deleteIfExists(directory.toPath());
  }
  else if (directory.exists()) {
    // exists but is file, not directory
    // either an error from the caller, or concurrently a file got created
    throw new IOException(directory + " is not a directory");
  }
  // else: does not exist, which is okay (as if deleted)
}

相关文章