Write ZipEntry Data To String

前端 未结 4 1543
你的背包
你的背包 2021-02-05 20:16

I have retrieved a zip entry from a zip file like so.

InputStream input = params[0];
ZipInputStream zis = new ZipInputStream(input);

ZipEntry entry;
try {
    w         


        
4条回答
  •  余生分开走
    2021-02-05 20:55

    I would use apache's IOUtils

    ZipEntry entry;
    InputStream input = params[0];
    ZipInputStream zis = new ZipInputStream(input);
    
    try {
      while ((entry = zis.getNextEntry())!= null) {
        String entryAsString = IOUtils.toString(zis, StandardCharsets.UTF_8);
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    IOUtils.closeQuietly(zis);
    

提交回复
热议问题