Java CRC crcFromStream(InputStream stream)

Here you can find the source of crcFromStream(InputStream stream)

Description

crc From Stream

License

Open Source License

Declaration

public static long crcFromStream(InputStream stream) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.io.IOException;
import java.io.InputStream;
import java.util.zip.CRC32;

public class Main {
    public static long crcFromStream(InputStream stream) throws IOException {
        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();
    }//w  ww .j  a  va  2s.  co  m
}

Related

  1. crc(String tempStr)
  2. crc32(File f)
  3. crc32(final InputStream input)
  4. crc32(String data)