fixed sonar bugs
This commit is contained in:
@ -1,7 +1,3 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package de.muehlencord.shared.util.file;
|
||||
|
||||
import static de.muehlencord.shared.util.StringUtil.getStackTraceString;
|
||||
@ -20,7 +16,6 @@ import java.text.Format;
|
||||
import static java.util.Arrays.asList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.apache.log4j.Logger;
|
||||
import static org.apache.log4j.Logger.getLogger;
|
||||
|
||||
@ -170,17 +165,17 @@ public abstract class FileUtil {
|
||||
throw new IOException("Cannot get MD5 MessageDigest instance");
|
||||
}
|
||||
|
||||
try (InputStream is = Files.newInputStream(Paths.get(fileName))) {
|
||||
DigestInputStream dis = new DigestInputStream(is, md);
|
||||
int nread;
|
||||
try (InputStream is = Files.newInputStream(Paths.get(fileName));
|
||||
DigestInputStream dis = new DigestInputStream(is, md)) {
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
while ((nread = dis.read(buffer)) != -1) {
|
||||
while ((dis.read(buffer)) != -1) {
|
||||
md.update(buffer);
|
||||
}
|
||||
}
|
||||
byte[] digest = md.digest();
|
||||
|
||||
//convert the byte to hex format method 1
|
||||
//convert the byte to hex format method 1
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < digest.length; i++) {
|
||||
sb.append(Integer.toString((digest[i] & 0xff) + 0x100, 16).substring(1));
|
||||
|
||||
Reference in New Issue
Block a user