简体   繁体   English

读取BufferedReader

[英]Reading a BufferedReader

Is there a way I can create some type of listener that listens to see if there is new data in a BufferedReader? 有没有一种方法可以创建某种类型的侦听器,以侦听BufferedReader中是否有新数据? I know I can use something like a while loop and keep seeing if it can be read but even in a async task this seems to block. 我知道我可以使用while循环之类的东西,继续查看它是否可以读取,但是即使在异步任务中,它似乎也会阻塞。

Basically what I want to do is listen to a sockets input stream for new data. 基本上,我想做的是侦听套接字输入流中的新数据。

Everything in java.io is blocking-mode. java.io中的所有内容都是阻塞模式。 The usual technique is to have a dedicated reading thread. 通常的技术是拥有专用的阅读线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM