java 如何将多个文件打包成一个zip后进行下载
2个回答
展开全部
打包压缩的如下:
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);
代码大致如此,请参考。
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);
代码大致如此,请参考。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |