以下是我的两个代码片段:
public class Uploader {
private static final String SHA_256 = "SHA-256";
public String getFileSHA2Checksum(InputStream fis) throws IOException {
try {
MessageDigest md5Digest = MessageDigest.getInstance(SHA_256);
return getFileChecksum(md5Digest, fis);
} catch (NoSuch算法rithmException e) {
return "KO";
}
}
public void transferTo(InputStream fis) throws IOException {
FileUtils.copyInputStreamToFile(fis, file2);
}
我的代码将此类用作:
有没有可能同时利用InputStream
打开copyToFile
和calculateChecksum
?