标题
支付宝官方文档地址:
https://opendocs.alipay.com/apis/api_15/alipay.data.dataservice.bill.downloadurl.query
作用:
为方便商户快速查账,支持商户通过本接口获取商户离线账单下载地址
代码实现:
pom:
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.0.7</version>
</dependency>
工具类:
package com.lwjwlkj.common.util;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.apache.commons.compress.utils.IOUtils;
import java.io.*;
/**
* @Author: CL
* @Date: 2020/6/23 13:11
* @Description: 解压工具类
*/
@Slf4j
public class ZipUtil {
public static void unzip(File zipFile, String filePath) {
try (ZipArchiveInputStream inputStream = getZipFile(zipFile)) {
ZipArchiveEntry entry = null;
while ((entry = inputStream.getNextZipEntry()) != null) {
if (entry.isDirectory()) {
File directory = new File(filePath, entry.getName());
directory.mkdirs();
} else {
OutputStream os = null;
try {
os = new BufferedOutputStream(new FileOutputStream(new File(filePath, entry.getName())));
//输出文件路径信息
System.out.println(entry.getName());
IOUtils.copy(inputStream, os);
} finally {
IOUtils.closeQuietly(os);
}
}
}
} catch (Exception e) {
log.error("unzip" + e);
}
}
private static ZipArchiveInputStream getZipFile(File zipFile) throws Exception {
return new ZipArchiveInputStream(new FileInputStream(zipFile), "GBK");
}
public static void makdirs(String filePath) {
File pathFile = new File(filePath);
if (!pathFile.exists()) {
pathFile.mkdirs();
}
}
public static void delAllFile(String path) {
File file = new File(path);
String[] tempList = file.list();
File temp = null;
for (int i = 0; i < tempList.length; i++) {
if (path.endsWith(File.separator)) {
temp = new File(path + tempList[i]);
} else {
temp = new File(path + File.separator + tempList[i]);
}
if (temp.isFile()) {
temp.delete();
}
if (temp.isDirectory()) {
delAllFile(path + "/" + tempList[i]);//先删除文件夹里面的文件
}
}
}