I have a list of files named as file001-file002...file099
. I used the following code to sort them but still my files are listed as file001-file010-file011...file002-file020...
while they should be sorted alphabetically as file001 file002 file003 file004 file005 ...file099
.
How to fix this?
File folder = new File("g:\");
File[] listOfFiles = folder.listFiles();
Arrays.sort(listOfFiles);
for (File file : listOfFiles) {
if (file.isFile()) {
//do sth
}
}
EDIT
I would like my files to be ordered based on their name alphanumerically:
file001
file002
file003
file004
file005
...file099