public class FileUtil extends Object
| 构造器和说明 |
|---|
FileUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static boolean |
copyFileToPath(String sourcePath,
String toPath,
String fileName)
复制指定路径的路径文件到指定路径
|
static void |
deleteFileByFolder(String path)
删除指定路径下面所有文件
|
static void |
deleteFileByPath(String path)
删除指定文件
|
static void |
fileIsExists(String path)
如果指定路径不存在,则创建
|
static String |
getFileMD5(File file)
计算文件的MD5值
|
static String |
getFileSha1(File file)
计算文件的 SHA-1 值
|
static String |
getProjectClassPath()
获取项目的编译路径
|
static String |
getProjectPath()
获取工程路径
|
static Map<String,String> |
getPropertiesKeyValue(String path,
String readType)
获取properties中的key,value的对应值都取出来
|
static String |
joinFilName(String path,
String join)
遍历指定文件夹下的文件名并用关键字连接起来
|
static String |
md5(String content)
MD5签名
|
static void |
printTxtToFile(String path,
String value)
将内容输出到文件
|
static String |
readProperties(String path,
String readType,
String readKey,
String defaultValue)
读取properties文件
|
static Properties |
readPropertiesUtil(String path,
String readType)
读取properties辅助类
|
static List<String> |
readTxt(String path)
读取txt文件,返回读取之后的内容
|
public static void fileIsExists(String path)
path - 路径public static void printTxtToFile(String path, String value) throws Exception
path - 路径value - 输出值Exception - 输出异常public static String joinFilName(String path, String join)
path - 路径join - 连接分割public static String getProjectPath()
public static String getProjectClassPath()
public static void deleteFileByFolder(String path) throws Exception
path - 路径Exception - 删除异常public static void deleteFileByPath(String path) throws Exception
path - 路径Exception - 删除异常public static boolean copyFileToPath(String sourcePath, String toPath, String fileName)
sourcePath - 原路径toPath - 目标路径fileName - 文件名称public static String readProperties(String path, String readType, String readKey, String defaultValue)
path - 读取路径readType - 读取方式:NETWORK是通过http://..方式读取,LOCAL是通过本地读取readKey - 要获得指定key对应的值defaultValue - 如果key对应的值不存在获取的默认值public static Map<String,String> getPropertiesKeyValue(String path, String readType)
path - 路径readType - 读取类型public static Properties readPropertiesUtil(String path, String readType)
path - 路径readType - 读取类型Copyright © 2017-6-20–2017. All rights reserved.