|
@@ -61,8 +61,11 @@ public class FssHelper {
|
|
* 获取文件的MD5值
|
|
* 获取文件的MD5值
|
|
*/
|
|
*/
|
|
public static String getFileMD5(File file) {
|
|
public static String getFileMD5(File file) {
|
|
- if (file == null || !file.isFile()) {
|
|
|
|
- return null;
|
|
|
|
|
|
+ if (file == null) {
|
|
|
|
+ throw new RuntimeException("文件不能为空!");
|
|
|
|
+ }
|
|
|
|
+ if (!file.isFile()) {
|
|
|
|
+ throw new RuntimeException("文件类型不能正确!");
|
|
}
|
|
}
|
|
|
|
|
|
try (FileInputStream fis = new FileInputStream(file);) {
|
|
try (FileInputStream fis = new FileInputStream(file);) {
|
|
@@ -77,7 +80,7 @@ public class FssHelper {
|
|
return new String(Hex.encodeHex(md.digest()));
|
|
return new String(Hex.encodeHex(md.digest()));
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error(e.getMessage(), e);
|
|
log.error(e.getMessage(), e);
|
|
- return null;
|
|
|
|
|
|
+ throw new RuntimeException("获取文件的MD5值失败!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|