How can I generate zip file without saving to the disk with Java?

后端 未结 2 442
盖世英雄少女心
盖世英雄少女心 2021-01-01 21:04

I have generated many BufferedImages in memory and I want to compress them into one zip file before sending it as a email attachment. How do I save the files to a zip withou

2条回答
  •  醉酒成梦
    2021-01-01 21:57

                 FileInputStream[] ins = //I assume you have all file handles in the form of FileInputStream
                 String[] fileNames = //I assume you have all file names
                 FileOutputStream out = new FileOutputStream(""); //specify the zip file name here
                 ZipOutputStream zipOut = new ZipOutputStream(out);
                 for (int i=0; i

    Based on the information you have provided, I come up with the code above. Hope this helps.

提交回复
热议问题