I Am Not Getting the Result I Expect Using readLine() in Java

前端 未结 3 860
一向
一向 2021-01-05 21:20

I am using the code snippet below, however it\'s not working quite as I understand it should.

public static void main(String[] args) {
    BufferedReader         


        
3条回答
  •  Happy的楠姐
    2021-01-05 21:52

    No input is not the same as the end of the stream. You can usually simulate the end of the stream in a console by pressing Ctrl+D (AFAIK some systems use Ctrl+Z instead). But I guess this is not what you want so better test for empty strings additionally to null strings.

提交回复
热议问题