Capture the content of standard output in Java

I'm calling a function that prints some strings in my console / standard output I need to capture this string I cannot modify the printing function in progress, nor can I change the runtime behavior through inheritance I can't find any predefined methods, which will allow me to do so

Does the JVM store a buffer for print content?

Who knows a Java method that can help me?

Solution

You can temporarily replace system. Net with a stream written to a string buffer Err or system out.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>