Does anyone know why in the Java Socket class, getInputStream reads bytes from the socket, while getOutputStream writes bytes to the socket? Intuitively I feel like reading should be an output stream, while writing should be an input stream.
1 Answer
The streams are named from your perspective. An input stream is a place where data is input to your program, and an output stream is a place where your program outputs data to.
No different from FileIn-/OutputStream, or System.in/out.
Even java.lang.Process is named this way (confusingly) - the getOutputStream method returns the other process's input stream, which you can write data to.