java 如何将多个文件打包成一个zip后进行下载
发布网友
发布时间:2022-04-22 13:02
我来回答
共2个回答
热心网友
时间:2023-10-14 20:45
打包压缩的如下:
ZipOutputStream out=new ZipOutputStream(new FileOutputStream(zipFileName));
for(int i=0;i<fileList.size();i++){
String filename = (String)fileList.get(i);
File file = new File(filename);
zip(out,file);
}
out.close();
下载的如下:
private int blockSize=65000;
File file = new File(sourceFilePathName);
FileInputStream fileIn = new FileInputStream(file);
int readBytes = 0;
readBytes = fileIn.read(b, 0, blockSize);
totalRead += readBytes;
out.write(b, 0, readBytes);
代码大致如此,请参考。
热心网友
时间:2023-10-14 20:46
用MyEclipse有自带的打包