There is a MapMap, it transfers data to an array. In the array, the data is sorted, everything is fine. It is necessary to make such a method to take only 5 pieces from the array after sorting, which begin with the given letters.
For example, I entered abc and he returned to you a list of 5 values ββthat start with abc.
The main thing is that exactly 5 values ββand the order of the files should not be lost (they are already sorted by date \ alphabet)
public static void main(String[] args) { TreeMap<File, Class> classesByFiles = find("com.company", ""); // ΠΏΠΎΠ»ΡΡΠΈΠ» ΠΌΠ°ΠΏΡ List<File> files = new ArrayList<>(classesByFiles.keySet()); //ΠΏΠΎΠ»ΡΡΠΈΠ» ΡΠΏΠΈΡΠΎΠΊ ΡΠ°ΠΉΠ»ΠΎΠ² ΠΈΠ· ΠΌΠ°ΠΏΡ Collections.sort(files, MODIFIED_DATE_FILE_COMPARATOR);// ΠΏΠΎΡΠΎΡΡΠΈΡΠΎΠ²Π°Π» for (File file : files) // ΠΈΠ΄Π΅ΠΌ ΠΏΠΎ ΠΌΠ°ΡΡΠΈΠ²Ρ { System.out.println(file);// Π²ΡΠ²ΠΎΠ΄ΠΈΠΌ Π΅Π³ΠΎ Π½Π° ΠΏΠ΅ΡΠ°ΡΡ Π΄Π»Ρ ΠΏΡΠΎΠ²Π΅ΡΠΊΠΈ }
TreeMapkeys are also sorted. - pavel