response.setContentType("APPLICATION/OCTET-STREAM");
response.setHeader("Content-Disposition", "attachment; filename=images.zip");//images.zip为下载的压缩包的文件名
ZipOutputStream out = null;
try {
out = new ZipOutputStream(response.getOutputStream());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
for (String string : split) {
nameMap = db.searchToMap(" SELECT f_name de_name,f_url de_path,f_icon FROM T_TAILOR_FORM_FILE WHERE F_OBJID=?", new Object[] { string });
if (nameMap == null)
continue;
String fullpath = uploadURL + nameMap.get("de_path").toString();
String filename = nameMap.get("de_name").toString();
File file = new File(fullpath);
ZipEntry entry = new ZipEntry(filename);
out.putNextEntry(entry);
int len = 0 ;
byte[] buffer = new byte[1024];
FileInputStream fis = new FileInputStream(file);
while ((len = fis.read(buffer)) > 0) {
out.write(buffer, 0, len);
out.flush();
}
out.closeEntry();
fis.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
response.setHeader("Content-Disposition", "attachment; filename=images.zip");//images.zip为下载的压缩包的文件名
ZipOutputStream out = null;
try {
out = new ZipOutputStream(response.getOutputStream());
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
for (String string : split) {
nameMap = db.searchToMap(" SELECT f_name de_name,f_url de_path,f_icon FROM T_TAILOR_FORM_FILE WHERE F_OBJID=?", new Object[] { string });
if (nameMap == null)
continue;
String fullpath = uploadURL + nameMap.get("de_path").toString();
String filename = nameMap.get("de_name").toString();
File file = new File(fullpath);
ZipEntry entry = new ZipEntry(filename);
out.putNextEntry(entry);
int len = 0 ;
byte[] buffer = new byte[1024];
FileInputStream fis = new FileInputStream(file);
while ((len = fis.read(buffer)) > 0) {
out.write(buffer, 0, len);
out.flush();
}
out.closeEntry();
fis.close();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
try {
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}