I am writing a tool to scrape Javadoc from pre-existing Java source files and preprocess it via a custom doclet (the specifics of the processing are not relevant). I have written the doclet, and I'm able to invoke the doclet from my code via the programmatic API as indicated in the Java documentation.
It appears that this mechanism is "write-only" in the sense that the results of running the doclet, if any, cannot be transmitted back to the invoker of the execute() method through a first class Java object. Instead, I have to resort to a kludge such as writing intermediate output to a file from within the doclet and then reading that back in from my caller.
So my question: is there any way to retrieve, say, a String generated by my custom doclet directly at the invoker? For eg:
public void foo() {
// Invoke my custom doclet via Javadoc programmatically
com.sun.tools.javadoc.Main.execute(new String[] {"-d", "docs", "- sourcepath", "/home/usr/src", "p1", "p2"});
// Access the String output of my doclet here
String processedJavadoc = getTheOutputOfMyDoclet();
}
Thanks in advance!