Convert ZipOutputStream to ByteArrayInputStream
问题 I want to compress an InputStream using ZipOutputStream and then get the InputStream from compressed ZipOutputStream without saving file on disc. Is that possible? 回答1: I figured it out: public InputStream getCompressed( InputStream is ) throws IOException { byte data[] = new byte[2048]; ByteArrayOutputStream bos = new ByteArrayOutputStream(); ZipOutputStream zos = new ZipOutputStream( bos ); BufferedInputStream entryStream = new BufferedInputStream( is, 2048); ZipEntry entry = new ZipEntry(