org.apache.nifi.util.file.FileUtils.renameFile()方法的使用及代码示例

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

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

FileUtils.renameFile介绍

[英]Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories might not work well. See the File.renameTo for more information.
[中]将给定文件从源路径重命名为目标路径。这可以处理多次尝试。这只能用于在给定目录中重命名。跨目录重命名可能无法正常工作。有关更多信息,请参见File.renameTo

代码示例

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

/**
 * Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories
 * might not work well. See the <code>File.renameTo</code> for more information.
 *
 * @param source the file to rename
 * @param destination the file path to rename to
 * @param maxAttempts the max number of attempts to attempt the rename
 * @throws IOException if rename isn't successful
 */
public static void renameFile(final File source, final File destination, final int maxAttempts) throws IOException {
  FileUtils.renameFile(source, destination, maxAttempts, false);
}

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

FileUtils.renameFile(tempFile.toFile(), configFile.toFile(), 5, true);
} catch (final FlowSerializationException fse) {
  throw new IOException(fse);

代码示例来源:origin: org.apache.nifi/nifi-utils

/**
 * Renames the given file from the source path to the destination path. This handles multiple attempts. This should only be used to rename within a given directory. Renaming across directories
 * might not work well. See the <code>File.renameTo</code> for more information.
 *
 * @param source the file to rename
 * @param destination the file path to rename to
 * @param maxAttempts the max number of attempts to attempt the rename
 * @throws IOException if rename isn't successful
 */
public static void renameFile(final File source, final File destination, final int maxAttempts) throws IOException {
  FileUtils.renameFile(source, destination, maxAttempts, false);
}

相关文章