Why ZipInputStream can't read the output of ZipOutputStream?

后端 未结 5 1981
夕颜
夕颜 2021-01-18 08:20

I\'m stuck with this junit test:

public void test() throws Exception {
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ZipOutputStream zipOu         


        
5条回答
  •  青春惊慌失措
    2021-01-18 08:50

    You actually have to read the contents of the entry, then entry.getSize() will return the correct size.

    To read entry use:

        byte[] buf = new byte[1024];
        int len;
        while ((len = zipIn.read(buf)) > 0) {
            // use data;
        }
    

提交回复
热议问题