Sorting text files by DateTime in content

released 0.3.2. It supports filtering text files by the vaue of Email header value (such as “To: xyz.com”) AND sorting the files by the lastModifiled property of java.io.File.

You can perform it like this:

...
List<IPathComparable> files =
    Files.list(this.dir)
        filter(p -> p.getFileName().toString().endsWith(".eml"))
        // filter files with "To: xyz.com" header
        .map(p -> new PathComparableByContentEmailHeaderValue(p, "To"))
        .filter(p -> p.getValue().matches("xyz.com"))
        // to sort by the lastModified timestamp
        .map(p -> new PathComparableByFileLastModified(p.get()))
        .sorted(reverseOrder())
        .collect(Collectors.toList());
...

The javadoc is here


1 Like