JSON

Wizzers World(11)

字号+ 作者:H5之家 来源:H5之家 2016-07-02 10:00 我要评论( )

源码: int i = 0;File f = Globals.FILE_POOL.createFile(".zip");ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f.getAbsolutePath()));for (Weixin_image image : list) {i++;String filenam

源码:

int i = 0; File f = Globals.FILE_POOL.createFile(".zip"); ZipOutputStream out = new ZipOutputStream(new FileOutputStream(f.getAbsolutePath())); for (Weixin_image image : list) { i++; String filename = Strings.sNull(bbinfo.get(image.getUid())) + "_" + Strings.sNull(userinfo.get(image.getUid())) + "_" + i+".jpg"; String picurl = image.getPicurl(); if (!Strings.isBlank(image.getImage_url())) { picurl = image.getImage_url(); } URL url = new URL(picurl); try { URLConnection conn = url.openConnection(); InputStream inStream = conn.getInputStream(); byte[] buffer = new byte[1204]; out.putNextEntry(new ZipEntry(filename)); while ((byteread = inStream.read(buffer)) != -1) { bytesum += byteread; out.write(buffer, 0, byteread); } out.closeEntry(); inStream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } out.close(); resp.setHeader("Content-Length", "" + f.length()); resp.setHeader("Content-Disposition", "attachment; filename=\"" + tvShow.getPlay_name() + ".zip\""); Streams.writeAndClose(resp.getOutputStream(), Streams.fileIn(f));

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • 用JSON API插件搭建WordPress api,返回文章列表等信息 半白色

    用JSON API插件搭建WordPress api,返回文章列表等信息 半白色

    2015-11-18 09:23

网友点评
<