javaparser - Lexical error Encountered: <EOF> after : ""
<p>I am using this javaparser <a href="https://github.com/javaparser/javaparser" rel="nofollow">https://github.com/javaparser/javaparser</a> to parse a lot of java source codes of some github users to make some statistics from them (this is for a university project). Everything seems to work fine, but at some point, a particular source code produces this error:</p>

<pre><code>Exception in thread "main" com.github.javaparser.TokenMgrError: Lexical error at line 6, column 2.  Encountered: &lt;EOF&gt; after : ""
</code></pre>

<p>This is what is written in that file: </p>

<pre><code>public class Test {
    /**&lt;caret&gt;
    public void foo() {
    }
}
</code></pre>

<p>This is how I parse the file:</p>

<pre><code>...

new NodeIterator(new NodeIterator.NodeHandler() {
    @Override
    public boolean handle(Node node) {
        ...
    };
}).explore(JavaParser.parse(file));

...
</code></pre>

<p>This is the NodeIterator class:</p>

<pre><code>public class NodeIterator {
    public interface NodeHandler {
        boolean handle(Node node);
    }

    private NodeHandler nodeHandler;

    public NodeIterator(NodeHandler nodeHandler) {
        this.nodeHandler = nodeHandler;
    }

    public void explore(Node node) {
        if (nodeHandler.handle(node)) {
            for (Node child : node.getChildrenNodes()) {
                explore(child);
            }
        }
    }
}
</code></pre>

<p>I have understood the problem, but this problem stops the entire parsing. I have a lot of files to parse inside a for, so <strong>how can I do to keep parsing the other files</strong>? Or is there a tool to <strong>check if</strong> a java file is "<strong>well written</strong>" before parsing it?</p>