Java Utililty Methods CRC

List of utility methods to do CRC

  1. HOME
  2. Java
  3. C
  4. CRC

Description

The list of methods to do CRC are organized into topic(s).

Method

String crc(String tempStr)
Gnerate CRC String for tempStr
java.util.zip.Adler32 inChecker = new java.util.zip.Adler32();
java.util.zip.CheckedInputStream in = null;
in = new java.util.zip.CheckedInputStream(new java.io.ByteArrayInputStream(tempStr.getBytes()), inChecker);
@SuppressWarnings("unused")
int c;
while ((c = in.read()) != -1)
 c = 0;
String myCheckSum = "" + inChecker.getValue();
...
long crc32(File f)
crc
CheckedInputStream cis = new CheckedInputStream(new BufferedInputStream(new FileInputStream(f)),
 new CRC32());
try {
 while (cis.read() != -1) {
 return cis.getChecksum().getValue();
} finally {
 cis.close();
...
long crc32(final InputStream input)
crc
byte[] buffer = new byte[4096];
CRC32 crc = new CRC32();
crc.reset();
int n = 0;
while (EOF != (n = input.read(buffer))) {
 crc.update(buffer, 0, n);
return crc.getValue();
...
long crc32(String data)
Generates a CRC 32 Value of String passed
if (data == null) {
 return -1;
try {
 byte bytes[] = data.getBytes("UTF-8");
 Checksum checksum = new CRC32();
 checksum.update(bytes, 0, bytes.length);
 return checksum.getValue();
...
long crcFromStream(InputStream stream)
crc From Stream
CRC32 crc = new CRC32();
byte[] buffer = new byte[1024];
int length;
while ((length = stream.read(buffer)) != -1)
 crc.update(buffer, 0, length);
return crc.getValue();

AltStyle によって変換されたページ (->オリジナル) /