How to determine the exact state of a BufferedReader?

后端 未结 8 1665
慢半拍i
慢半拍i 2020-12-17 00:21

I have a BufferedReader (generated by new BufferedReader(new InputStreamReader(process.getInputStream()))). I\'m quite new to the concept of a

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-17 00:52

    You could use InputStream.available() to see if there is new output from the process. This should work the way you want it if the process outputs only full lines, but it's not really reliable.

    A more reliable approach to the problem would be to have a seperate thread dedicated to reading from the process and pushing every line it reads to some queue or consumer.

提交回复
热议问题