Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending System.out over socket

How do I send output from System.out to socket e.g. PrintWriter?

I need to send whatever appears on the console output (both std and err) to PrintWriter, thus a socket.

Thank you.


1 Answers

May be you can try like this:

OutputStream os = socket.getOutputStream(); // for example
PrintStream ps = new PrintStream(os);
System.setOut(ps);
like image 92
UVM Avatar answered Jan 20 '26 15:01

UVM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!