|
|
|
|
|
by RyanZAG
4462 days ago
|
|
Sure, but if you want to modify this code to send stdin over the network or through bluetooth in the Java version, you would just replace 'System.out' with the socket. The code would remain the same - in fact the whole class could be reused by having it pass in an input and output stream as parameters. Your example is very much just a special shortcut for one special condition. It's not generalizable in the same way. And let's be honest - most of today's code is not writing to standard output, it is writing to some iOS or Android GUI or outputting JSON to be used in some javascript webapp. That kind of shortcut just doesn't make sense anymore and is a relic of a different time. |
|
http://computer.howstuffworks.com/cgi3.htm
The server opens the socket, redirects the stdout to his socket while calling your program fully unmodified.