Greetings. Here is the situation. Data comes from the modem in the InputStream. I need to let them on the fly in the OutputStream. And the opposite situation ... I saw in the documentation such a nice thing as PipedInputStream and PipedOutputStream. Which are joined directly in the designer of their creation. What do you think of them? There it is written in the docks that it is not recommended to use both of them in one thread because of the danger of deadlock. But what a temptation!)))) In general, what do you think about sabzh and piped? thank

    1 answer 1

    This thing inside is very ugly implemented. Verdict: do not use. If only because you need to run some kind of additional stream .. which is still necessary to be destroyed somehow.

    Just copy bytes and that's it.

    byte[] buffer = new byte[256]; int rc; while ((rc = is.read(buffer)) != -1) os.write(buffer, 0, rc);