As a result of processing, some data files are written to disk.
- Count of files between 2 servers (MAC and Linux) match
- File names are identical between systems
- Files content is identical between systems, as measured by md5sum
Report is then computed based on content read from said files, using
for (File f : contentDirectory.listFiles()) {
// magic
.listFiles() javadoc says:
There is no guarantee that the name strings in the resulting array
will appear in any specific order; they are not, in particular,
guaranteed to appear in alphabetical order.
While that is true, i wonder … the order in which files will be listed, is not random, right? I mean, listing same files 2 times will produce the same results is this correct?
Does this mean that when files are listed on 2 different systems, order is likely to not be the same?
Ultimately the bigger question is, how to list files in a directory in same order regardless of OS file are stored on?
Just sort the files.
Fileis comparable so we don’t even need a comparator:(This example simply takes the files from the first root directory, that should have some content on every computer ;))
Alternative
The file objects should be unique so we can create a tree set: