// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Iterator;

public class ListFilesWithLimit {
    public static void main(String[] args) throws IOException {
        Iterator<Path> dir = Files.newDirectoryStream(Paths.get("/work")).iterator();
        int n = 0;
        while(dir.hasNext() && n < 10) {
            System.out.println(dir.next());
            n++;
        }
    }
}
