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

com.versionone.om.StreamComparer Maven / Gradle / Ivy

Go to download

A strongly-typed object model library on top of the VersionOne SDK.Java API Client library.

The newest version!
/*(c) Copyright 2008, VersionOne, Inc. All rights reserved. (c)*/
package com.versionone.om;

import java.io.IOException;
import java.io.InputStream;

/**
 * Comparator for streams.
 */
public class StreamComparer {

    /**
     * @param expected first stream.
     * @param actual second stream.
     * @return true if data in streams is equals, false - otherwise.
     * @throws IOException if occur any error with reading from any streams.
     */
    public static boolean compareStream(InputStream expected, InputStream actual)
            throws IOException {
        int i, j;

        if (expected == null || actual == null) return false;
        
        expected.reset();
        actual.reset();

        do {
            i = expected.read();
            j = actual.read();
            if (i != j) {
                return false;
            }
        } while ((i != -1) && (j != -1));

        return true;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy