java合并整形_Java:合并InputStreams(Java: merging InputStreams)
我的目標(biāo)是創(chuàng)建(或使用現(xiàn)有)一個(gè)InputStream實(shí)現(xiàn)(比如MergeInputStream),它將嘗試從多個(gè)InputStream中讀取并返回第一個(gè)結(jié)果。 之后,它將釋放鎖定并停止從所有InputStreams讀取,直到下一次mergeInputStream.read()調(diào)用。 我很驚訝我沒有找到任何這樣的工具。 問題是:所有的源InputStream都不是很有限(例如,不是文件,而是System.in,socket等),所以我不能使用SequenceInputReader。 我知道這可能需要一些多線程機(jī)制,但我完全不知道該怎么做。 我試著谷歌但沒有結(jié)果。
My goal is to create (or use existing) an InputStream implementation (say, MergeInputStream) that will try to read from a multiple InputStreams and return the first result. After that it will release lock and stop reading from all InputStreams until next mergeInputStream.read() call. I was quite surprised that I didn't found any such tool. The thing is: all of the source InputStreams are not quite finite (not a file, for example, but a System.in, socket or such), so I cannot use SequenceInputReader. I understand that this will probably require some multi-thread mechanism, but I have absolutely no idea how to do it. I tried to google it but with no result.
原文:https://stackoverflow.com/questions/3931199
總結(jié)
以上是生活随笔為你收集整理的java合并整形_Java:合并InputStreams(Java: merging InputStreams)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为手机充满有提醒吗_华为推出的联发科天
- 下一篇: ftl不存在为真_FreeMarker