Examples of CheckedInputStream


Examples of java.util.zip.CheckedInputStream

*/
public final class ChecksumHelper
{
    public static long getChecksum(InputStream is)
    {
        CheckedInputStream cis = null;       
        long checksum = 0;
        try
        {
            cis = new CheckedInputStream(is, new Adler32());
            byte[] tempBuf = new byte[128];
            while (cis.read(tempBuf) >= 0)
            {
            }
            checksum = cis.getChecksum().getValue();
        }
        catch (IOException e)
        {
            checksum = 0;
        }
        finally
        {
            if (cis != null)
            {
                try
                {
                    cis.close();
                }
                catch (IOException ioe)
                {                   
                }
            }
View Full Code Here

Examples of java.util.zip.CheckedInputStream

*/
public class MultiFileChecksumHelper
{
    public static long getChecksum(File[] files)
    {
        CheckedInputStream cis = null;
        FileInputStream is = null;
        Checksum checksum = new Adler32();
        byte[] tempBuf = new byte[128];
       
        for ( int i = 0; i < files.length && files[i] != null && files[i].exists() && files[i].isFile(); i++ )
        {
            try
            {
                is = new FileInputStream(files[i]);
                cis = new CheckedInputStream(is, checksum);
                while (cis.read(tempBuf) >= 0) {}               
            }
            catch (Exception e)
            {
                throw new RuntimeException(e);
            }
            finally
            {
                if (cis != null)
                {
                    try
                    {
                        cis.close();
                    }
                    catch (IOException ioe) {}
                    cis = null;
                }
                if (is != null)
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.