org.rhq.core.util.stream
Class StreamCopyDigest

java.lang.Object
  extended by org.rhq.core.util.stream.StreamCopyDigest

public class StreamCopyDigest
extends Object

This copies stream data to another stream, while calculating the stream's message digest on the fly as the copy is performed.

Author:
John Mazzitelli

Constructor Summary
StreamCopyDigest()
           
StreamCopyDigest(MessageDigestGenerator generator)
           
 
Method Summary
 String copyAndCalculateHashcode(InputStream in, OutputStream out)
          Copies the input stream data to the output stream and returns the copied data's digest string.
 MessageDigestGenerator getMessageDigestGenerator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamCopyDigest

public StreamCopyDigest()

StreamCopyDigest

public StreamCopyDigest(MessageDigestGenerator generator)
Method Detail

getMessageDigestGenerator

public MessageDigestGenerator getMessageDigestGenerator()
Returns:
the generator used to calculate digests/hashcodes

copyAndCalculateHashcode

public String copyAndCalculateHashcode(InputStream in,
                                       OutputStream out)
Copies the input stream data to the output stream and returns the copied data's digest string. Note: the streams are never closed - the caller is responsible for that.

Parameters:
in - input content
out - where to write the input content
Returns:
the copied content's digest string (aka hashcode)


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.