com.bigzip.plugin.compression.io
Class CheckedStream
java.lang.Object
|
+--com.bigzip.plugin.compression.io.AbstractStream
|
+--com.bigzip.plugin.compression.io.CheckedStream
- public class CheckedStream
- extends AbstractStream
An access stream that also maintains a checksum of the data being
written or read. The checksum can then be used to verify the integrity of
the output data.
- See Also:
Checksum
Field Summary |
protected java.util.zip.Checksum |
ckm
|
Method Summary |
java.util.zip.Checksum |
getChecksum()
Returns the Checksum for this output stream. |
int |
read()
Reads a byte. |
int |
read(byte[] buf,
int off,
int len)
Reads into an array of bytes. |
int |
readDirect(byte[] buf,
int off,
int len)
Reads into an array of bytes bypassing the compression stream. |
void |
write(byte[] b,
int off,
int len)
Writes an array of bytes. |
void |
write(int b)
Writes a byte. |
void |
writeDirect(byte[] b,
int off,
int len)
Writes an array of bytes bypassing the compression stream. |
Methods inherited from class com.bigzip.plugin.compression.io.AbstractStream |
close, ensureOpen, finish, getFilePointer, isClosed, length, read, readBoolean, readByte, readChar, readDirect, readDouble, readFloat, readFully, readInt, readInt, readLine, readLong, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, seek, setClientStream, setClosed, skipBytes, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDirect, writeDouble, writeFloat, writeFully, writeInt, writeLong, writeShort, writeUTF |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ckm
protected java.util.zip.Checksum ckm
CheckedStream
public CheckedStream(AbstractStream clientStream,
java.util.zip.Checksum ckm)
- Creates an output stream with the specified Checksum.
- Parameters:
clientStream
- the random access stream.ckm
- error-checking class that extends @code Checksum- See Also:
Checksum
CheckedStream
public CheckedStream(AbstractStream clientStream)
- Creates an output stream with the CRC32 checksum scheme.
- Parameters:
clientStream
- The randonly accessible archive.
read
public int read()
throws java.io.IOException
- Reads a byte. Will block if no input is available.
- Overrides:
read
in class AbstractStream
- Returns:
- the byte read, or -1 if the end of the stream is reached.
- Throws:
java.io.IOException
- if an I/O error has occurred
read
public int read(byte[] buf,
int off,
int len)
throws java.io.IOException
- Reads into an array of bytes. Will block until some input
is available.
- Overrides:
read
in class AbstractStream
- Parameters:
buf
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes read- Returns:
- the actual number of bytes read, or -1 if the end
of the stream is reached.
- Throws:
java.io.IOException
- if an I/O error has occurred
readDirect
public int readDirect(byte[] buf,
int off,
int len)
throws java.io.IOException
- Reads into an array of bytes bypassing the compression stream.
Will block until some input is available.
- Overrides:
readDirect
in class AbstractStream
- Parameters:
buf
- the buffer into which the data is readoff
- the start offset of the datalen
- the maximum number of bytes read- Returns:
- the actual number of bytes read, or -1 if the end
of the stream is reached.
- Throws:
java.io.IOException
- if an I/O error has occurred
write
public void write(int b)
throws java.io.IOException
- Writes a byte. Will block until the byte is actually written.
- Overrides:
write
in class AbstractStream
- Parameters:
b
- the byte to be written- Throws:
java.io.IOException
- if an I/O error has occurred
write
public void write(byte[] b,
int off,
int len)
throws java.io.IOException
- Writes an array of bytes. Will block until the bytes are
actually written.
- Overrides:
write
in class AbstractStream
- Parameters:
buf
- the data to be writtenoff
- the start offset of the datalen
- the number of bytes to be written- Throws:
java.io.IOException
- if an I/O error has occurred
writeDirect
public void writeDirect(byte[] b,
int off,
int len)
throws java.io.IOException
- Writes an array of bytes bypassing the compression stream.
Will block until the bytes are actually written.
- Overrides:
writeDirect
in class AbstractStream
- Parameters:
buf
- the data to be writtenoff
- the start offset of the datalen
- the number of bytes to be written- Throws:
java.io.IOException
- if an I/O error has occurred
getChecksum
public java.util.zip.Checksum getChecksum()
- Returns the Checksum for this output stream.