本文整理了Java中org.apache.nifi.util.file.FileUtils.copyFile()
方法的一些代码示例,展示了FileUtils.copyFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyFile()
方法的具体详情如下:
包路径:org.apache.nifi.util.file.FileUtils
类名称:FileUtils
方法名:copyFile
[英]Copies the given source file to the given destination file. The given destination will be overwritten if it already exists.
[中]将给定的源文件复制到给定的目标文件。如果给定目标已存在,则将覆盖该目标。
代码示例来源:origin: apache/nifi
/**
* Copies the given source file to the given destination file. The given destination will be overwritten if it already exists.
*
* @param source the file to copy from
* @param destination the file to copy to
* @param lockInputFile if true will lock input file during copy; if false will not
* @param lockOutputFile if true will lock output file during copy; if false will not
* @param logger the logger to use
* @return long number of bytes copied
* @throws FileNotFoundException if the source file could not be found
* @throws IOException if unable to read or write to file
* @throws SecurityException if a security manager denies the needed file operations
*/
public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final Logger logger) throws FileNotFoundException, IOException {
return FileUtils.copyFile(source, destination, lockInputFile, lockOutputFile, false, logger);
}
代码示例来源:origin: apache/nifi
/**
* Syncs a primary copy of a file with the copy in the restore directory. If the restore directory does not have a file and the primary has a file, the the primary's file is copied to the restore
* directory. Else if the restore directory has a file, but the primary does not, then the restore's file is copied to the primary directory. Else if the primary file is different than the restore
* file, then an IllegalStateException is thrown. Otherwise, if neither file exists, then no syncing is performed.
*
* @param primaryFile the primary file
* @param restoreFile the restore file
* @param logger a logger
* @throws IOException if an I/O problem was encountered during syncing
* @throws IllegalStateException if the primary and restore copies exist but are different
*/
public static void syncWithRestore(final File primaryFile, final File restoreFile, final Logger logger)
throws IOException {
if (primaryFile.exists() && !restoreFile.exists()) {
// copy primary file to restore
copyFile(primaryFile, restoreFile, false, false, logger);
} else if (restoreFile.exists() && !primaryFile.exists()) {
// copy restore file to primary
copyFile(restoreFile, primaryFile, false, false, logger);
} else if (primaryFile.exists() && restoreFile.exists() && !isSame(primaryFile, restoreFile)) {
throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'",
primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath()));
}
}
代码示例来源:origin: apache/nifi
FileUtils.copyFile(tenantsFile, restoreTenantsFile, false, false, logger);
代码示例来源:origin: apache/nifi
FileUtils.copyFile(authorizationsFile, restoreAuthorizationsFile, false, false, logger);
代码示例来源:origin: org.apache.nifi/nifi-utils
/**
* Copies the given source file to the given destination file. The given destination will be overwritten if it already exists.
*
* @param source the file to copy from
* @param destination the file to copy to
* @param lockInputFile if true will lock input file during copy; if false will not
* @param lockOutputFile if true will lock output file during copy; if false will not
* @param logger the logger to use
* @return long number of bytes copied
* @throws FileNotFoundException if the source file could not be found
* @throws IOException if unable to read or write to file
* @throws SecurityException if a security manager denies the needed file operations
*/
public static long copyFile(final File source, final File destination, final boolean lockInputFile, final boolean lockOutputFile, final Logger logger) throws FileNotFoundException, IOException {
return FileUtils.copyFile(source, destination, lockInputFile, lockOutputFile, false, logger);
}
代码示例来源:origin: org.apache.nifi/nifi-utils
/**
* Syncs a primary copy of a file with the copy in the restore directory. If the restore directory does not have a file and the primary has a file, the the primary's file is copied to the restore
* directory. Else if the restore directory has a file, but the primary does not, then the restore's file is copied to the primary directory. Else if the primary file is different than the restore
* file, then an IllegalStateException is thrown. Otherwise, if neither file exists, then no syncing is performed.
*
* @param primaryFile the primary file
* @param restoreFile the restore file
* @param logger a logger
* @throws IOException if an I/O problem was encountered during syncing
* @throws IllegalStateException if the primary and restore copies exist but are different
*/
public static void syncWithRestore(final File primaryFile, final File restoreFile, final Logger logger)
throws IOException {
if (primaryFile.exists() && !restoreFile.exists()) {
// copy primary file to restore
copyFile(primaryFile, restoreFile, false, false, logger);
} else if (restoreFile.exists() && !primaryFile.exists()) {
// copy restore file to primary
copyFile(restoreFile, primaryFile, false, false, logger);
} else if (primaryFile.exists() && restoreFile.exists() && !isSame(primaryFile, restoreFile)) {
throw new IllegalStateException(String.format("Primary file '%s' is different than restore file '%s'",
primaryFile.getAbsoluteFile(), restoreFile.getAbsolutePath()));
}
}
内容来源于网络,如有侵权,请联系作者删除!