Boris
Boris

Reputation: 1136

Java - UnixFileSystem - how does list sort children?

In Windows code new File("").list() sorts files by name. In Linux (when java.io.UnixFileSystem is used) - files are sorted in some strange (but not random) way. Is this behaviour adjustable? Or at least - which alghorithm is used to sort files ?

I cannot sort files in my code because I use some standard library that I cannot (or don't want) to modify - therefore don't offer to do this, please.

There are results for tomcat lib directory:

jsp-api.jar  
catalina-ant.jar  
tomcat-i18n-fr.jar  
catalina.jar  
jasper.jar  
ecj-4.2.2.jar  
catalina-tribes.jar  
servlet-api.jar  
tomcat-jdbc.jar  
tomcat-coyote.jar  
tomcat-api.jar  
tomcat-util.jar  
postgresql-9.2-1003.jdbc3.jar  
tomcat-i18n-ja.jar  
catalina-ha.jar  
tomcat-dbcp.jar  
annotations-api.jar  
jasper-el.jar  
el-api.jar  
tomcat-i18n-es.jar  

Upvotes: 0

Views: 273

Answers (1)

subsub
subsub

Reputation: 1857

I guess that under the hood it's using readdir (or similar). So this answer also applies here, basically it points to this blog-post

Upvotes: 2

Related Questions