Using walkFileTree in a JavaScript source interpreted by rhino

126 Views Asked by At

If I do the following (JavaScript source):

Files.walkFileTree(Paths.get("somepath"), {
    visitFile: function(path, attr) {
        return FileVisitResult.CONTINUE;
    }
});

I always get Wrapped java.lang.NullPointerException: FileVisitor returned null.

Some one have an idea how to solve this?

Answer

As @SotiriosDelimanolis pointed, FileVisitor has other methods.

I was trying to @Override a method in SimpleFileVisitor, discovered that I could use JavaAdapter, but I think there is a bug related to the mechanism of overriding classes. So no way, we have to implement everything... :(

Files.walkFileTree(Paths.get("some/path"), {
    visitFile: function(path, attr) {
        return FileVisitResult.CONTINUE;
    },
    preVisitDirectory: function() {
        return FileVisitResult.CONTINUE;
    },
    visitFileFailed: function() {
        return FileVisitResult.CONTINUE;
    },
    postVisitDirectory: function() {
        return FileVisitResult.CONTINUE;
    }
});
0

There are 0 best solutions below