public final class FileUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static char |
PATH_SEPARATOR
文件路径分隔符
|
| 构造器和说明 |
|---|
FileUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
copy(InputStream is,
OutputStream os)
复制文件
|
static void |
copy(InputStream is,
String targetPath,
StandardOpenOption option)
复制文件
|
static void |
copy(String sourcePath,
String targetPath,
StandardOpenOption option)
复制文件
|
static void |
download(InputStream is,
String fileName,
String fileType,
javax.servlet.http.HttpServletResponse response)
文件下载
|
static void |
download(String sourcePath,
String fileName,
String fileType,
javax.servlet.http.HttpServletResponse response)
文件下载
|
static File |
getFile(String sourcePath,
StandardOpenOption option)
根据文件路径获取该文件
|
static String |
getRandomFileName(String pathOrName)
获取新的随机文件名
|
static boolean |
rename(File sourceFile,
String newName)
重命名文件
|
static void |
rename(String sourcePath,
String newName)
重命名文件
|
static String |
suffix(File file,
boolean isContainsDian)
获取文件后缀名
|
static String |
suffix(String pathOrName,
boolean isContainsDian)
获取文件后缀名
|
public static String suffix(File file, boolean isContainsDian) throws Exception
file - isContainsDian - 后缀是否包含. 如:true —— .text .doc .xml;false —— text doc xmlExceptionpublic static String suffix(String pathOrName, boolean isContainsDian) throws Exception
pathOrName - 文件路径或文件名isContainsDian - 后缀是否包含. 如:true —— .text .doc .xml;false —— text doc xmlExceptionpublic static String getRandomFileName(String pathOrName) throws Exception
pathOrName - Exceptionpublic static File getFile(String sourcePath, StandardOpenOption option) throws Exception
sourcePath - 文件绝对路径option - 文件操作模式FileNotFoundExceptionExceptionpublic static void copy(String sourcePath, String targetPath, StandardOpenOption option) throws Exception
sourcePath - 源文件绝对路径targetPath - 目标文件绝对路径option - 目标文件模式Exceptionpublic static void copy(InputStream is, String targetPath, StandardOpenOption option)
is - 源文件输入流targetPath - 目标文件绝对路径option - 目标文件模式Exceptionpublic static void copy(InputStream is, OutputStream os)
is - 源文件输入流os - 目标文件输出流Exceptionpublic static void rename(String sourcePath, String newName) throws Exception
sourcePath - 源文件绝对路径newName - 重命名文件的新文件名,注:不需要文件的后缀Exceptionpublic static boolean rename(File sourceFile, String newName) throws Exception
sourceFile - 源文件newName - 重命名文件的新文件名,注:不需要文件的后缀Exceptionpublic static void download(String sourcePath, String fileName, String fileType, javax.servlet.http.HttpServletResponse response) throws Exception
sourcePath - 源文件绝对路径fileName - 文件名称fileType - 文件路径response - Exceptionpublic static void download(InputStream is, String fileName, String fileType, javax.servlet.http.HttpServletResponse response)
is - 源文件输入流fileName - 文件名称fileType - 文件路径response - ExceptionCopyright © 2018. All rights reserved.