Calculate multiple checksums from the same InputStream using DigestInputStream
问题 I am trying to figure out how to read multiple digests (md5, sha1, gpg) based on the same InputStream using DigestInputStream . From what I've checked in the documentation, it seems to be possible by cloning the digest. Could somebody please illustrate this? I don't want to be re-reading the stream in order to calculate the checksums. 回答1: You could wrap a DigestInputStream around a DigestInputStream and so on recursively: DigestInputStream shaStream = new DigestInputStream( inStream,