Ref: do not re-invent the wheel, use existing lib

This commit is contained in:
Laurent Clouet
2025-01-11 12:16:47 +01:00
parent 4bb085d418
commit 086e084b3c

View File

@@ -150,9 +150,9 @@ public class DirectoryManager {
} }
else { else {
try { try {
String extension = file.getName().substring(file.getName().lastIndexOf('.')).toLowerCase(); String extension = FilenameUtils.getExtension(file.getName()).toLowerCase();
String name = file.getName().substring(0, file.getName().length() - 1 * extension.length()); String name = FilenameUtils.removeExtension(file.getName());
if (".wool".equals(extension)) { if ("wool".equals(extension)) {
// check if the md5 of the file is ok // check if the md5 of the file is ok
String md5_local = Utils.md5(file.getAbsolutePath()); String md5_local = Utils.md5(file.getAbsolutePath());
@@ -166,7 +166,7 @@ public class DirectoryManager {
file.delete(); file.delete();
} }
} }
catch (StringIndexOutOfBoundsException e) { // because the file does not have an . in his path catch (IllegalArgumentException e) { // because the file does not have an . in his path
file.delete(); file.delete();
} }
} }