BufferedReader, detecting if there is text left to read

后端 未结 3 1881
盖世英雄少女心
盖世英雄少女心 2021-01-06 00:33

I\'m running a thread and everytime it runs, It should be checking to see if there is a new line to read from the BufferedReader although, it gets stuck waiting

3条回答
  •  别那么骄傲
    2021-01-06 01:10

    No, there's no easy way to do that. BufferedReader has a ready call, but that only applies to the read calls, not the readLine call. If you really want a readLine that's guaranteed not to block, you must implement it yourself using read and maintaining a char buffer yourself.

提交回复
热议问题