I ran into a funny situation because java's File.listFiles() method returns a list of Files in a directory without any guarantees on the order. One class reads some information from all files in a directory using this listFiles() method and writes to an OutputStream. A corresponding JUnit test cases tries to compare the data written to the output stream with some expected byteArray. The test passed on my dev machine and the production stack, but failed on a dev server because it uses a different OS and a different version of Java.
In how to File.listFiles in alphabetical order? the solution is to force the sorting of the array returned from File.listFiles(). But I am not comfortable about this solution because it is doing some extra work just so the JUnit test can pass.
So I am just wondering if there is a better way. Any advice? Thanks