How to stop reading multiple lines from stdin using Scanner?

后端 未结 4 1897
暗喜
暗喜 2021-02-06 05:28

I\'m working on an JAVA assignment should process multiple lines of input. The instructions read \"Input is read from stdin.\"

An example of sample input is given:

4条回答
  •  [愿得一人]
    2021-02-06 05:43

    From the shell, hit Ctrl-D and it will close stdin. Alternatively, pipe input in

    cat your-input-file | java Test
    

提交回复
热议问题