Code example for ZipEntry

Methods: setCrcsetMethodsetSize

0
 
@Provider 
@Produces("application/zip") 
public class ZipWriter implements MessageBodyWriter<Map<String, byte[]>> {
  private static void zipStoreBuffer(ZipArchiveOutputStream zip, String name, byte[] dataBuffer) throws IOException {
    ZipEntry zipEntry = new ZipEntry(name!=null?name: UUID.randomUUID().toString());
    zipEntry.setMethod(ZipOutputStream.STORED);
 
    zipEntry.setSize(dataBuffer.length);
    CRC32 crc32 = new CRC32();
    crc32.update(dataBuffer);
    zipEntry.setCrc(crc32.getValue());
 
    try { 
      zip.putArchiveEntry(new ZipArchiveEntry(zipEntry));
    } catch (ZipException ex) {
      if (name!=null) {
        zipStoreBuffer(zip, "x-"+name, dataBuffer);
        return; 
      } 
Connect your IDE to all the code out there  Get Codota for Java