1. 递归查询文件夹
文章图片
2.删除目录(文件夹)以及目录下的文件
文章图片
3.删除单个文件
文章图片
4. 创建目录
【File文件工具类】
文章图片
5.IO流文件复制
public void copyFile(File source, File target){
InputStream inputStream = null;
OutputStream outputStream = null;
try{
inputStream = new BufferedInputStream(new FileInputStream(source));
outputStream = new BufferedOutputStream(new FileOutputStream(target));
int c;
byte[] bytes = new byte[1024];
while ((c = inputStream.read(bytes)) != -1){
outputStream.write(bytes, 0 ,c);
}
}catch (Exception ex){
log.error("-------ex:{}", ex);
}finally {
try {
inputStream.close();
outputStream.close();
}catch (IOException ioEx){
log.error("finally_IOException: {}", ioEx.getMessage());
}
}
}
6.复制文件/文件夹以及子文件夹下的文件; Copy file/folder including subfolder/files
文章图片