I am attempting to redirect the console output of a Java library to a JTextArea in my application. The library in question is JPL, a bridge between Java and SWI-Prolog (though I doubt this has much relevance conceptually).
Here is my code:
PrintStream out = new PrintStream(new MyOutputStream(), true, "UTF-8");
System.setOut(out);
System.setErr(out);
System.out.println("This text is successfully redirected.");
Hashtable<String, Term> solutions[] = Query.allSolutions("append([1],[2],[1,2])");
When I run this code, the string "This text is successfully redirected" is redirected to my PrintStream as expected. However, the last line of the above snippet generates some text output which is still printed at the Java console instead of in my PrintStream.
What could the method allSolutions(String)
be doing so that its output is not redirected? Could it be the fact that it calls an OS process that generates the output (it does call the swipl process)? If so, can I redirect its output without modifying the JPL code?