public class FileTools extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static String |
FILE_CHARACTER_GBK
文本文件GBK编码
|
static String |
FILE_CHARACTER_UTF8
文本文件UTF-8编码
|
| 构造器和说明 |
|---|
FileTools() |
| 限定符和类型 | 方法和说明 |
|---|---|
static void |
copy(String defaultfile,
String langfile)
复制文件
如果文件不存在,则创建
|
static void |
copyFiles(File sourceFile,
File desFile)
拷贝某个文件目录下面的所有文件,
|
static boolean |
deleteDirectory(File dirFile)
删除目录(文件夹)以及目录下的文件
|
static boolean |
deleteFile(File delFile)
删除单个文件
|
boolean |
deleteFolder(File delFolder)
根据路径删除指定的目录或文件,无论存在与否
|
static void |
extract(String source,
String target)
解压zip文件
|
static String |
getFileContet(File filePath,
String character)
获取文本文件内容
|
static String |
getStreamContent(InputStream __fis,
String character) |
static String |
getSuffix(String path)
获取文件名称后缀
|
static void |
load(String path,
Properties pro)
加载配置文件 to Properties对象
采用编码:UTF-8
|
static Object |
readObject(String url)
读取持久化文件
|
static void |
setFileContet(File filePath,
String content,
String character)
写入文本文件内容
|
static void |
store(String profile,
Properties pro)
持久化Properties文件
|
static void |
writeObject(String path,
Object obj)
写入对象到持久化文件
|
public static final String getFileContet(File filePath, String character) throws IOException
filePath - 文件路径character - 字符编码IOException - 异常public static final void setFileContet(File filePath, String content, String character) throws IOException
filePath - 文件路径character - 字符编码content - 内容IOException - 异常public static final String getStreamContent(InputStream __fis, String character) throws IOException
IOExceptionpublic boolean deleteFolder(File delFolder)
delFolder - 路径
要删除的目录或文件public static boolean deleteFile(File delFile)
delFile - 被删除文件的文件名public static boolean deleteDirectory(File dirFile)
dirFile - 被删除目录的文件路径public static void load(String path, Properties pro) throws IOException
pro - 配置path - 路径IOException - 异常public static void store(String profile, Properties pro) throws IOException
profile - 路径pro - 配置IOException - 异常public static Object readObject(String url) throws IOException, ClassNotFoundException
url - URL地址IOException - 异常ClassNotFoundException - 异常public static void writeObject(String path, Object obj) throws IOException
path - 路径obj - 对象IOException - 异常public static void extract(String source, String target) throws Exception
source - zip文件target - 解压目标文件夹Exception - 异常public static void copy(String defaultfile, String langfile) throws IOException
defaultfile - 默认文件langfile - 语言文件IOException - 异常public static void copyFiles(File sourceFile, File desFile) throws IOException
sourceFile - 原文件目录desFile - 目的文件目录IOException - 异常Copyright © 2017. All rights reserved.