Decided to put the question differently, suppose we have a file-test, there is a lot of different files, some of this type indeks.html, kiki.tht, lololo.bin and so on, to get the names of all files in a folder, you can use this code:
File folder = new File("C:\\test\\");
File[] listOfFiles = folder.listFiles();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].isFile()) {
System.out.println(listOfFiles[i].getName());
}
}
But how to display only the file name without the extension? Indeks.html looolo.tht not like (just remember files in the lot, there is no duplicate names), and the index and looolo)
1 Answer