Code example for CRC32

Methods: getValueupdate

0
  public static void zipStoreBuffer(ZipOutputStream 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.putNextEntry(zipEntry);
    } catch (ZipException ex) {
      if (name!=null) {
        zipStoreBuffer(zip, null, dataBuffer);
        return; 
      } 
    } 
 
    zip.write(dataBuffer);
 
Experience pair programming with AI  Get Codota for Java