public class Files extends Object
| 构造器和说明 |
|---|
Files() |
| 限定符和类型 | 方法和说明 |
|---|---|
void |
copy(File inputFile,
File outputFile,
boolean isOverWrite)
复制文件或者文件夹
|
void |
deleteAll(String dirpath)
删除所有文件,包括文件夹
|
byte[] |
getBytesByFilepath(String filePath)
Author : Wuwenbin
Title : getBytesByFilepath Description : 获得指定文件的byte数组 |
void |
getFileByByte(byte[] bfile,
String filePath,
String fileName)
Author : Wuwenbin
Title : getFileByByte Description : 根据byte数组,生成文件 |
String |
getFileMD5(File file)
获取文件的MD5
|
long |
getFileSize(File file)
获取指定文件的大小
|
String |
getFileSuffix(String file)
获取文件的后缀
|
byte[] |
inputStream2ByteArray(InputStream input)
Author : Wuwenbin
Title : inputStream2ByteArray Description : 根据流生成byte数组二进制 |
boolean |
isExist(String filePath,
boolean isNew) |
boolean |
renameDir(String oldPath,
String newPath)
文件重命名
|
public boolean isExist(String filePath, boolean isNew)
filePath - 指定的文件路径isNew - true:新建、false:不新建public long getFileSize(File file) throws Exception
file - Exceptionpublic void deleteAll(String dirpath)
dirpath - public void copy(File inputFile, File outputFile, boolean isOverWrite) throws IOException
inputFile - 源文件outputFile - 目的文件isOverWrite - 是否覆盖文件IOExceptionpublic boolean renameDir(String oldPath, String newPath)
oldPath - 老文件newPath - 新文件public byte[] getBytesByFilepath(String filePath)
filePath - public void getFileByByte(byte[] bfile,
String filePath,
String fileName)
bfile - filePath - fileName - public byte[] inputStream2ByteArray(InputStream input) throws IOException
input - IOExceptionCopyright © 2017. All rights reserved.