I'm reading multiple text files using Java and printing their directories and I wonder why the output is not alphabetically arranged?
Code Snippet (got it from the internet also)
File dir = new File("/home/dilapitan/Desktop/xml-parsing/files/");
File[] listOfFiles = dir.listFiles();
for (File path : listOfFiles) {
System.out.println(path);
}
Output:
dilapitan@NT071855:~/Desktop/xml-parsing$ java Multiple
/home/dilapitan/Desktop/xml-parsing/files/c.txt
/home/dilapitan/Desktop/xml-parsing/files/b.txt
/home/dilapitan/Desktop/xml-parsing/files/a.txt
dilapitan@NT071855:~/Desktop/xml-parsing$
Can I do it with the output being:
a.txt
b.txt
c.txt
Thank you in advance!