Class FileCopier
java.lang.Object
cloud.opencode.base.io.file.FileCopier
File Copier Utility
文件复制器
Fluent API for copying files and directories with various options. Supports recursive copying and file attribute preservation.
用于复制文件和目录的流式API。 支持递归复制和文件属性保留。
Features | 主要功能:
- Fluent API - 流式API
- Recursive copy - 递归复制
- Attribute preservation - 属性保留
- Replace existing option - 替换现有文件选项
Usage Examples | 使用示例:
// Copy file
FileCopier.copy(source, target);
// Copy with replace
FileCopier.from(source).to(target).replaceExisting().execute();
// Copy directory recursively
FileCopier.from(sourceDir).to(targetDir).recursive().execute();
Security | 安全性:
- Thread-safe: Yes - 线程安全: 是
- Since:
- JDK 25, opencode-base-io V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic PathCopies a file directly 直接复制文件Enables copy attributes 启用复制属性static PathcopyReplace(Path source, Path target) Copies a file with replace option 使用替换选项复制文件execute()Executes the copy operation 执行复制操作static FileCopierCreates a file copier from source string 从源字符串创建文件复制器static FileCopierCreates a file copier from source 从源创建文件复制器Gets the source path 获取源路径Gets the target path 获取目标路径Enables recursive copy for directories 启用目录递归复制Enables replace existing 启用替换现有文件Sets the target path string 设置目标路径字符串Sets the target path 设置目标路径
-
Method Details
-
from
Creates a file copier from source 从源创建文件复制器- Parameters:
source- the source path | 源路径- Returns:
- file copier | 文件复制器
-
from
Creates a file copier from source string 从源字符串创建文件复制器- Parameters:
source- the source path string | 源路径字符串- Returns:
- file copier | 文件复制器
-
copy
-
copyReplace
-
to
Sets the target path 设置目标路径- Parameters:
target- the target path | 目标路径- Returns:
- this | 当前对象
-
to
Sets the target path string 设置目标路径字符串- Parameters:
target- the target path string | 目标路径字符串- Returns:
- this | 当前对象
-
replaceExisting
-
copyAttributes
-
recursive
-
execute
-
getSource
-
getTarget
-