Java CRC crc32(final InputStream input)

Here you can find the source of crc32(final InputStream input)

Description

crc

License

Apache License

Declaration

public static long crc32(final InputStream input) throws IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.*;

import java.util.zip.CRC32;

public class Main {
    private static final int EOF = -1;

    public static long crc32(final InputStream input) throws IOException {
        byte[] buffer = new byte[4096];
        CRC32 crc = new CRC32();
        crc.reset();/*from   w ww .ja va 2 s  .  c  o  m*/
        int n = 0;
        while (EOF != (n = input.read(buffer))) {
            crc.update(buffer, 0, n);
        }
        return crc.getValue();
    }
}

Related

  1. crc(String tempStr)
  2. crc32(File f)
  3. crc32(String data)
  4. crcFromStream(InputStream stream)