|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream jut.io.InputCountStream jut.io.HashInputStream
public class HashInputStream
InputStream
calculating a hash for the bytes read. the methods
InputCountStream.skip(long)
, InputCountStream.mark(int)
and InputCountStream.reset()
are not supported and throw an
UnsupportedOperationException
.
Field Summary |
---|
Fields inherited from class jut.io.InputCountStream |
---|
baseStream, counter |
Constructor Summary | |
---|---|
HashInputStream(File file,
String algorithm)
create a new InputStream calculating a hash for the bytes read. for creating
the stream, the Streams.input(File) method is used. |
|
HashInputStream(File file,
String algorithm,
int capacity)
create a new InputStream with push back functionality calculating a hash for
the bytes read. for creating the stream, the Streams.input(File) method is used. |
|
HashInputStream(InputStream stream,
String algorithm)
create a new InputStream calculating a hash for the bytes read. |
|
HashInputStream(InputStream stream,
String algorithm,
int capacity)
create a new InputStream with push back functionality calculating a hash for
the bytes read. if the hash algorithm is not provided, an appropriate NestedException
is thrown. |
Method Summary | |
---|---|
void |
close()
the HashInputStream must be closed before the hash result can be read. |
String |
hash()
returns the hash string for this HashInputStream . note that the HashInputStream
must be closed before the hash result can be read. |
byte[] |
hashDigest()
returns the hash digest for this HashInputStream . note that the HashInputStream
must be closed before the hash result can be read. |
Long |
lastModified()
returns the modification time stamp of the underlying file if known, else null . |
void |
unread(byte[] bytes)
pushes back an array of bytes by copying it to the front of the pushback buffer. note that the hash is created from the data read originally, i.e., if data different from the data read is pushed back and read again, the hash does not change. |
void |
unread(byte[] bytes,
int off,
int len)
pushes back a portion of an array of bytes by copying it to the front of the pushback buffer. |
void |
unread(int oneByte)
pushes back a byte by copying it to the front of the pushback buffer. note that the hash is created from the data read originally, i.e., if data different from the data read is pushed back and read again, the hash does not change. |
Methods inherited from class jut.io.InputCountStream |
---|
available, getCount, getCounter, mark, markSupported, read, read, read, reset, skip |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public HashInputStream(File file, String algorithm) throws FileNotFoundException
InputStream
calculating a hash for the bytes read. for creating
the stream, the Streams.input(File)
method is used.
file
- - the file to open the InputStream
for.algorithm
- - the hash algorithm to use as defined in MessageDigest.getAlgorithm()
FileNotFoundException
- if the file cannot be opened for reading.public HashInputStream(InputStream stream, String algorithm)
InputStream
calculating a hash for the bytes read.
stream
- - the stream to calculate a hash for.algorithm
- - the hash algorithm to use as defined in MessageDigest.getAlgorithm()
public HashInputStream(File file, String algorithm, int capacity) throws FileNotFoundException
InputStream
with push back functionality calculating a hash for
the bytes read. for creating the stream, the Streams.input(File)
method is used.
file
- - the file to open the InputStream
for.algorithm
- - the hash algorithm to use as defined in MessageDigest.getAlgorithm()
capacity
- - the capacity of the push back buffer as defined in PushbackInputStream
.
FileNotFoundException
- if the file cannot be opened for reading.public HashInputStream(InputStream stream, String algorithm, int capacity)
InputStream
with push back functionality calculating a hash for
the bytes read. if the hash algorithm is not provided, an appropriate NestedException
is thrown.
stream
- - the stream to calculate a hash for.algorithm
- - the hash algorithm to use as defined in MessageDigest.getAlgorithm()
capacity
- - the capacity of the push back buffer as defined in
PushbackInputStream
.Method Detail |
---|
public void unread(byte[] bytes) throws IOException
bytes
- - the byte array to push back.
IOException
- if there is not enough room in the pushback buffer for the specified number
of bytes, or this input stream has been closed by invoking its close()
method.public void unread(byte[] bytes, int off, int len) throws IOException
bytes
- - the byte array to push back.off
- - the start offset of the data.len
- - the number of bytes to push back.
IOException
- if there is not enough room in the pushback buffer for the specified number
of bytes, or this input stream has been closed by invoking its close()
method.public void unread(int oneByte) throws IOException
oneByte
- - the int value whose low-order byte is to be pushed back.
IOException
- if there is not enough room in the pushback buffer for the byte, or this
input stream has been closed by invoking its close()
method.public void close() throws IOException
HashInputStream
must be closed before the hash result can be read.
close
in interface Closeable
close
in class InputCountStream
IOException
public byte[] hashDigest() throws IllegalStateException
HashInputStream
. note that the HashInputStream
must be closed before the hash result can be read.
HashInputStream
.
IllegalStateException
- if trying to access the hash result while the stream is still open.public String hash() throws IllegalStateException
HashInputStream
. note that the HashInputStream
must be closed before the hash result can be read.
HashInputStream
.
IllegalStateException
- if trying to access the hash result while the stream is still open.public Long lastModified()
null
.
null
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |