Input and Output Stream Pipe in Java

后端 未结 7 1733
闹比i
闹比i 2020-12-17 21:18

Does anyone have any good suggestions for creating a Pipe object in Java which is both an InputStream and and OutputStream since Java does not have multiple inherit

7条回答
  •  无人及你
    2020-12-17 21:46

    java.io.PipedOutputStream and java.io.PipedInputStream look to be the classes to use for this scenario. They are designed to be used together to pipe data between threads.

    If you really want some single object to pass around it would need to contain one of each of these and expose them via getters.

提交回复
热议问题