How can I redirect the output of session.setDebug(true) so that I can capture it in the program that uses it?

John Zukowski

The messages are hardcoded to go to System.out. The best you can do is redirect System.out to a ByteArrayOutputStream:

session.setDebug(true);
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(os);
// save output
PrintStream old = System.out;
// change output
System.setOut(ps);
// send
...
// reset output
System.setOut(old);
System.out.println(os);
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact