If the difference is not so great, then we have InAndOutStream instead of making code for two classes (InputStream and OutputStream)?
This is not possible, with the exception of the ByteArray classes. The reason is that most threads are supported by system devices such as a file or socket. In the case of a file, the file you are writing is the file you are reading, but in the case of a socket, the stream you are writing does not depend on the stream you are reading.
Even an attempt to combine them would be a bad idea IMHO, as people are embarrassed between text and binary streams. If they could read and write in the same stream, you would become even more confused, I suspect.
In general, developers should have a clear idea of โโwhether they are read or written from the device. If they do not understand this, you will have problems.
FYI: I wrote a library that does exactly what you offer in the memory stream, for example, "pipe";) However, I would say that this is only for experienced developers, and even then I keep the interfaces as clear as possible to prevent confusion.
source share