开发者

File read by interrupt in java

I am using a text file to store the serial port output. And now I want to put the contents of the file to an textArea in java. I have created a dedicated thread for file read operation. I need the thread to sleep when ther开发者_Go百科e is no data to read and thread should wake up automatically once data available for read in the file. In the thread I am using a while loop and using readLine() method for reading from file. But when data not available when readLine called in while loop the loop exits and thread terminates. Can anybody suggest how to implement this?


You can use FIFO pipe (man mkfifo) and write the serial port output data to it instead of the file, or both into the FIFO and into the file (man tee).

The reason why the loop exits is, as far as I understand, that you're hitting the end of file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜