I wanted to ask if this is a better way to find a latest file in given directory. This is my current approach:

```
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.FileTime;
import java.time.ZoneId;
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class FilesOperations {

    public static void main(String[] args) throws IOException {

        Set<Path> pathSet = getFilesFromDirectory("C:some/path/");

        iteratePaths(pathSet);

        getLatestFile(pathSet);
    }

    public static Set<Path> getFilesFromDirectory(String directory) {

        Set<Path> pathSet = new HashSet<>();

        Pattern pattern = Pattern.compile("(test\\d-)(\\d{12})(\\.txt)");
        Path lookUpPath = Paths.get(directory);

        Stream<Path> stream = null;
        try {
            stream = Files.find(lookUpPath, 1, (path, basicFileAttributes) -> {
                File file = path.toFile();
                return !file.isDirectory() && pattern.matcher(file.getName()).matches();
            });

            stream.forEach(path -> {
                pathSet.add(path);
            });

        } catch (IOException e) {
            e.printStackTrace();
        }

        stream.close();
        return pathSet;
    }

    public static void iteratePaths(Set<Path> pathSet) {
        pathSet.stream().forEach(path -> {
            System.out.println(path);
        });
    }

    public static Path getLatestFile(Set<Path> pathSet) throws IOException {

        long fileTime = 0;
        Path pathToReturn = null;
        BasicFileAttributes attr = null;

        for (Path path : pathSet) {
            attr = getBasicFileAttributes(path);
            if (attr.creationTime().toMillis() > fileTime) {
            fileTime = attr.creationTime().toMillis();
                pathToReturn = path;
            }
        }

        attr = getBasicFileAttributes(pathToReturn);
        System.out.println("Latest file: " + pathToReturn + " - " + attr.creationTime().toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
        return pathToReturn;
    }

    private static BasicFileAttributes getBasicFileAttributes(Path pathToReturn) throws IOException {
        BasicFileAttributes attr;
        attr = Files.readAttributes(pathToReturn, BasicFileAttributes.class);
        return attr;
    }

}

```

I know this is quite simple without any sophisticated solutions, but it works. I hope you can point some places for improvements. If you have some ideas, how to refactor code to use more streams, it would be great (e.g. in `getLatestFile()` ).