Write ZipEntry Data To String

前端 未结 4 1544
你的背包
你的背包 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:58

    you have to read from the ZipInputStream:

    StringBuilder s = new StringBuilder();
    byte[] buffer = new byte[1024];
    int read = 0;
    ZipEntry entry;
    while ((entry = zis.getNextEntry())!= null) {
          while ((read = zis.read(buffer, 0, 1024)) >= 0) {
               s.append(new String(buffer, 0, read));
          }
    }
    

    When you exit from the inner while save the StringBuilder content, and reset it.

提交回复
热议问题