The issue is that i get extra 2 elements in listOf_sorted_APPFiles from somewhere.
Map<String, List<APPfile>> APPfilesMapByFileName
= new HashMap<String, List<APPfile>>();
...
Collections.sort(fileNames, String.CASE_INSENSITIVE_ORDER);
logger.debug("Sorted count " + fileNames.size()); // 77
// There will always be a list. Most of the time it will contains
// 1 element, but sometimes it may contains more
for (String sortedFileName : fileNames) {
for (APPfile a: APPfilesMapByFileName.get(sortedFileName)) {
listOf_sorted_APPFiles.add(a);
}
}
logger.debug("listOf_sorted_APPfiles count: " +
listOf_sorted_APPfiles.size()); // 79
...
I expect counts of listOf_sorted_APPFiles and fileNames to match, yet somehow i get extra 2 elements. Elements that are added extra are the ones coming from lists that contain more then one element.
You have two nested “for”. So, if sometimes there happen more than one element of APPfilesMapByFileName with the same filename, you MUST have more output elements.