There’s a class I’m working with that has a display() function that prints some information to the screen. I am not allowed to change it. Is there a way to “catch” the string it prints to the screen externally?
It displays to the console.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The closest thing I can come up with would be to catch and forward everything printed through
System.out.Have a look at the
setOut(java.io.PrintStream)method.A complete example would be: