public static String getMD5Checksum(String filePath) throws Exception {
File file = new File(filePath);
FileInputStream fis = new FileInputStream(file);
return DigestUtils.md5Hex(fis);
}
在上面的代码中,fis没有关闭,但在SonarQube中没有报错。DigestUtils.md5Hex方法也没有关闭流。 SonarQube和Sonar Java插件都是最新版本。