加载中...
The Wayback Machine - https://sup1a9wrlpyh5li9ro.vcoronado.top/web/20090405184549/http://developer.android.com:80/reference/java/security/DigestInputStream.html
public class

DigestInputStream

extends FilterInputStream
java.lang.Object
   ↳ java.io.InputStream
     ↳ java.io.FilterInputStream
       ↳ java.security.DigestInputStream

Summary

Fields
protected MessageDigest digest
[Expand]
Inherited Fields
From class java.io.FilterInputStream
Public Constructors
DigestInputStream(InputStream stream, MessageDigest digest)
Public Methods
MessageDigest getMessageDigest()
Returns the MessageDigest which the receiver uses when computing the hash.
void on(boolean on)
Enables or disables the digest function (default is on).
int read(byte[] b, int off, int len)
Reads at most count bytes from this FilterInputStream and stores them in byte array buffer starting at offset.
int read()
Reads the next byte and returns it as an int.
void setMessageDigest(MessageDigest digest)
Sets the MessageDigest which the receiver will use when computing the hash.
String toString()
Returns a string containing a concise, human-readable description of the receiver.
[Expand]
Inherited Methods
From class java.io.FilterInputStream
From class java.io.InputStream
From class java.lang.Object
From interface java.io.Closeable

Fields

protected MessageDigest digest

Public Constructors

public DigestInputStream (InputStream stream, MessageDigest digest)

Public Methods

public MessageDigest getMessageDigest ()

Returns the MessageDigest which the receiver uses when computing the hash.

Returns
  • MessageDigest the digest the receiver uses when computing the hash.

public void on (boolean on)

Enables or disables the digest function (default is on).

Parameters
on boolean true if the digest should be computed, and false otherwise.
See Also

public int read (byte[] b, int off, int len)

Reads at most count bytes from this FilterInputStream and stores them in byte array buffer starting at offset. Answer the number of bytes actually read or -1 if no bytes were read and end of stream was encountered. This implementation reads bytes from the target stream.

Parameters
b the byte array in which to store the read bytes.
off the offset in buffer to store the read bytes.
len the maximum number of bytes to store in buffer.
Returns
  • the number of bytes actually read or -1 if end of stream.
Throws
IOException

public int read ()

Reads the next byte and returns it as an int. Updates the digest for the byte if this function is enabled.

Returns
  • int the byte which was read or -1 at end of stream.
Throws
IOException If reading the source stream causes an IOException.

public void setMessageDigest (MessageDigest digest)

Sets the MessageDigest which the receiver will use when computing the hash.

Parameters
digest MessageDigest the digest to use when computing the hash.

public String toString ()

Returns a string containing a concise, human-readable description of the receiver.

Returns
  • String a printable representation for the receiver.