All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.albertus82.util.CRC32OutputStream Maven / Gradle / Ivy

Go to download

Java SWT/JFace Utility Library including a Preferences Framework, Lightweight HTTP Server and macOS support.

There is a newer version: 20.1.0
Show newest version
package io.github.albertus82.util;

import java.util.zip.CRC32;
import java.util.zip.Checksum;

/**
 * This class implements an output stream that can be used to compute the CRC-32
 * of a data stream. The checksum value can be retrieved using
 * getValue() (long) and toString() (hexadecimal).
 * 

* Closing a {@code CRC32OutputStream} has no effect. The methods in this class * can be called after the stream has been closed without generating an * {@code IOException}. *

* * @see Checksum */ public class CRC32OutputStream extends ChecksumOutputStream { /** * Creates a new CRC32OutputStream object. */ public CRC32OutputStream() { super(new CRC32(), 32); } /** * Updates the CRC-32 checksum with the specified array of bytes. * * @param b the array of bytes to update the checksum with */ @Override public void write(final byte[] b) { checksum.update(b); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy