List<File> getFiles(List<Path> files) {
        Validation.requireAtLeast(maxFilesToRead, "count must be a positive number", 1);
        List<File> fileList = new ArrayList<>();

        for (Path p : files) {
            File f = p.toFile();
            if (!f.isDirectory()) {
                fileList.add(f);
            }

            // Grab only some files
            if (fileList.size() > maxFilesToRead) {
                break;
            }
        }

        fileList.sort(ordering);
        return fileList;
    }
Spooler that will write an entry to a file and read files that are ready to be sent.
Files are written in JSON Lines text file format.

@author hmusum
container-search/src/main/java/com/yahoo/search/logging/Spooler.java