/**
*
* @param files 下载的文件组
* @param busiDate 营业日
* @param path 文件所在目录
* @param branchCode 网点的机构代码
*/
public void downVoucher(File[] files,String busiDate,String path,String branchCode){
if(files.length <= 0)
return;
byte[] bt=new byte[8192];
String strzipName = path+"\\"+branchCode+".zip";
String strs = branchCode+".zip";
try {
ZipOutputStream zout=new ZipOutputStream(new FileOutputStream(strzipName));
//循环下载每个文件并读取内容
for(int j=0;j<files.length;j++){
FileInputStream is=new FileInputStream(files[j]);
ZipEntry ze=new ZipEntry(URLEncoder.encode(files[j].getName(), "UTF-8"));//设置文件编码格式
zout.putNextEntry(ze);
int len;
//读取下载文件内容
while((len=is.read(bt))>0){
zout.write(bt, 0, len);
}
zout.closeEntry();
is.close();
}
zout.close();
this.toUpload(this.getResponse(),path,strs);//调用下载方法
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
本文介绍了一个用于批量压缩指定目录下文件的方法,并将其上传至服务器的功能实现。该方法接收文件数组、业务日期、文件路径及机构代码作为参数,通过循环遍历文件并逐个压缩,最终将压缩后的文件进行上传。

1万+

被折叠的 条评论
为什么被折叠?



