How to asynchronously read stdin?

前端 未结 5 601
遥遥无期
遥遥无期 2021-01-14 05:23

Is there an elegant way to fire an event when characters are available from System.in? I\'d like to avoid polling InputStream.available().

5条回答
  •  情书的邮戳
    2021-01-14 06:24

    Sure...start a thread that blocks on the input and then calls your event method when it gets something.

提交回复
热议问题