Class OpenPath
java.lang.Object
cloud.opencode.base.io.OpenPath
Path Utility Class
路径工具类
Utility class for path operations including extension handling, normalization, and path manipulation.
用于路径操作的工具类,包括扩展名处理、规范化和路径操作。
Features | 主要功能:
- Extension handling - 扩展名处理
- Path normalization - 路径规范化
- Path manipulation - 路径操作
- Unique file generation - 唯一文件生成
Usage Examples | 使用示例:
// Get extension
String ext = OpenPath.getExtension(path); // "txt"
// Get name without extension
String name = OpenPath.getNameWithoutExtension(path); // "file"
// Change extension
Path newPath = OpenPath.changeExtension(path, "md");
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 PathchangeExtension(Path path, String newExtension) Changes file extension 更改文件扩展名static StringgetExtension(String filename) Gets the file extension from filename 从文件名获取扩展名static StringgetExtension(Path path) Gets the file extension 获取文件扩展名static StringgetFileName(Path path) Gets file name from path 从路径获取文件名static intgetNameCount(Path path) Gets path name count 获取路径名称数量static StringgetNameWithoutExtension(String filename) Gets filename without extension from filename string 从文件名字符串获取不含扩展名的文件名static StringgetNameWithoutExtension(Path path) Gets filename without extension 获取不含扩展名的文件名static PathGets parent directory 获取父目录static PathGets root path 获取根路径static booleanisAbsolute(Path path) Checks if path is absolute 检查是否为绝对路径static booleanisSameFile(Path path1, Path path2) Checks if two paths point to the same file 检查两个路径是否指向同一文件static booleanChecks if child is a sub path of parent 检查子路径是否为父路径的子路径static PathJoins multiple path segments 连接多个路径段static PathJoins path with more segments 连接路径与更多段static PathNormalizes path 规范化路径static Pathrelativize(Path base, Path target) Gets relative path 获取相对路径static PathResolves path 解析路径static PathtoAbsolute(Path path) Converts to absolute path 转换为绝对路径static PathtoRealPath(Path path) Gets real path (resolves symbolic links) 获取真实路径(解析符号链接)static PathuniqueFile(Path dir, String baseName, String extension) Generates a unique filename in directory 在目录中生成唯一文件名
-
Method Details
-
getExtension
-
getExtension
-
getNameWithoutExtension
-
getNameWithoutExtension
-
changeExtension
-
normalize
-
relativize
-
resolve
-
getParent
-
getRoot
-
isAbsolute
Checks if path is absolute 检查是否为绝对路径- Parameters:
path- the path | 路径- Returns:
- true if absolute | 如果是绝对路径返回true
-
toAbsolute
-
toRealPath
-
isSubPath
-
uniqueFile
-
getFileName
-
isSameFile
-
getNameCount
Gets path name count 获取路径名称数量- Parameters:
path- the path | 路径- Returns:
- name count | 名称数量
-
join
-
join
-