I'm reading the filenames/directories of all the files within a folder into an array of Files.
The filesnames are all of the type:
Name1, Name2, Name3, Name4, Name5, Name6, Name7, Name8, Name9, Name10, Name11, Name12, Name13
The above shows the correct order in which the files should be ordered.
However, what java does is the following:
Name1, Name10, Name11, Name12, Name13, Name2, Name3, Name4, Name5, Name6, Name7, Name8, Name9
Here is the code I used:
JFileChooser folderChooser = new JFileChooser();
folderChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
int returnVal = folderChooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File directory = folderChooser.getSelectedFile();
File files[] = directory.listFiles();
Arrays.sort(files);
}
for (int i = 0; i < files.length; i++){
String test = files[i].getName();
System.out.println(test);
}
Any ideas for an easy fix?