Assuming JTidy prints errors and warnings to stdout, you can just temporarily change where System.out
calls go:
PrintStream originalOut = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream myOutputStream = new PrintStream(baos);
System.setOut(myOutputStream);
// your JTidy code here
String capturedOutput = new String(baos.toByteArray(), StandardCharsets.UTF_8);
System.setOut(originalOut);
// Send capturedOutput to a JTextArea
myTextArea.append(capturedOutput);
There is an analogous method if you need to do this for System.err
instead/as well.