public class FilenameUtils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
EXTENSION_SEPARATOR
文件名和文件类型的分隔符
|
static String |
LINUX_SEPARATOR
LINUX系统下目录分隔符
|
static String |
WINDOWS_SEPARATOR
Windows下的目录分隔符
|
| 构造器和说明 |
|---|
FilenameUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
applyRelativePath(String path,
String relativePath)
将相对路径
relativePath转为相对于path路径下的文件路径
StringUtils.applyRelativePath("/opt/app/config.properties", "/xml/jdbc.xml"); //--- /opt/app/xml/jdbc.properties
StringUtils.applyRelativePath("/opt/app/config/", "/xml/jdbc.xml"); //--- /opt/app/config/xml/jdbc.properties
|
static String |
getFileExt(File file)
从文件路径中提取文件后缀名
StringUtils.getFileExt("/opt/app/config.properties"); //--- properties
|
static String |
getFileExt(String path)
从文件路径中提取文件后缀名
StringUtils.getFileExt("/opt/app/config.properties"); //--- properties
|
static String |
getFilename(String path)
从文件路径中提取文件名,不支持Windows系统下的路径
StringUtils.getFilename("/opt/app/config.properties"); //--- config.properties
|
static String |
stripFilenameSuffix(String path)
从文件路径中删除文件后缀名
StringUtils.stripFilenameSuffix("/opt/app/config.properties"); //--- /opt/app/config
|
public static String getFilename(String path)
StringUtils.getFilename("/opt/app/config.properties"); //--- config.properties
path - 文件路径null如果为空时public static String getFileExt(String path)
StringUtils.getFileExt("/opt/app/config.properties"); //--- properties
path - 文件路径null如果为空时public static String getFileExt(File file)
StringUtils.getFileExt("/opt/app/config.properties"); //--- properties
file - 文件路径null如果为空时public static String stripFilenameSuffix(String path)
StringUtils.stripFilenameSuffix("/opt/app/config.properties"); //--- /opt/app/config
path - 文件路径public static String applyRelativePath(String path, String relativePath)
将相对路径relativePath转为相对于path路径下的文件路径
StringUtils.applyRelativePath("/opt/app/config.properties", "/xml/jdbc.xml"); //--- /opt/app/xml/jdbc.properties
StringUtils.applyRelativePath("/opt/app/config/", "/xml/jdbc.xml"); //--- /opt/app/config/xml/jdbc.properties
path - 路径(一般是文件的绝对路径)relativePath - 相对路径Copyright © 2017. All rights reserved.