MCPcopy Create free account
hub / github.com/cinit/TMoe / calculateFileMd5

Method calculateFileMd5

app/src/main/java/cc/ioctl/tmoe/util/IoUtils.java:166–180  ·  view source on GitHub ↗
(@NonNull InputStream is)

Source from the content-addressed store, hash-verified

164 }
165
166 @NonNull
167 public static byte[] calculateFileMd5(@NonNull InputStream is) throws IOException {
168 Objects.requireNonNull(is, "is == null");
169 try (is) {
170 MessageDigest md = MessageDigest.getInstance("MD5");
171 byte[] buf = new byte[8192];
172 int len;
173 while ((len = is.read(buf)) != -1) {
174 md.update(buf, 0, len);
175 }
176 return md.digest();
177 } catch (NoSuchAlgorithmException e) {
178 throw new IOException("No MD5 algorithm found", e);
179 }
180 }
181
182 @NonNull
183 public static byte[] calculateFileMd5(@NonNull File file) throws IOException {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected