This commit is contained in:
Looly 2023-02-28 22:48:00 +08:00
parent 82be78e2fd
commit 1141d57cfd

View File

@ -6,9 +6,9 @@ import cn.hutool.core.io.stream.EmptyOutputStream;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.nio.file.Files;
import java.util.zip.CRC32; import java.util.zip.CRC32;
import java.util.zip.CheckedInputStream; import java.util.zip.CheckedInputStream;
import java.util.zip.Checksum; import java.util.zip.Checksum;
@ -57,8 +57,8 @@ public class ChecksumUtil {
throw new IllegalArgumentException("Checksums can't be computed on directories"); throw new IllegalArgumentException("Checksums can't be computed on directories");
} }
try { try {
return checksum(new FileInputStream(file), checksum); return checksum(Files.newInputStream(file.toPath()), checksum);
} catch (final FileNotFoundException e) { } catch (final IOException e) {
throw new IORuntimeException(e); throw new IORuntimeException(e);
} }
} }