Oracle

com.compoze.util
Class XorChecksumOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by com.compoze.util.XorChecksumOutputStream
All Implemented Interfaces:
java.io.Closeable, java.io.Flushable, java.io.Serializable

public class XorChecksumOutputStream
extends java.io.OutputStream
implements java.io.Serializable

This class is an output stream that performs a simple xor checksum of all of the data that's being written.

See Also:
Serialized Form

Constructor Summary
XorChecksumOutputStream()
          Constructor.
 
Method Summary
 long getChecksum()
          Get the current value of the checksum.
static void main(java.lang.String[] args)
          Exerciser.
 void write(byte[] bytes)
          Write an array of bytes.
 void write(byte[] bytes, int iOffset, int iLength)
          Write an array of bytes.
 void write(int b)
          Write a single byte.
 
Methods inherited from class java.io.OutputStream
close, flush
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XorChecksumOutputStream

public XorChecksumOutputStream()
Constructor.

Parameters:
os - the underlying OutputStream
Method Detail

write

public void write(int b)
Write a single byte.

Specified by:
write in class java.io.OutputStream
Parameters:
b - the byte to write

write

public void write(byte[] bytes)
Write an array of bytes.

Overrides:
write in class java.io.OutputStream
Parameters:
bytes - the array to write

write

public void write(byte[] bytes,
                  int iOffset,
                  int iLength)
Write an array of bytes.

Overrides:
write in class java.io.OutputStream
Parameters:
bytes - the array to write

getChecksum

public long getChecksum()
Get the current value of the checksum.

Returns:
the checksum

main

public static void main(java.lang.String[] args)
Exerciser.


Oracle

Copyright ©1999-2008 Oracle All rights reserved.