Scanner使ってるときに、ctrl+dで送れるはずのEOFでhasNext()が終わったり終わらなかったりしてもにょもにょする問題の対策
環境
Version: Luna Service Release 2 (4.4.2)
こういうのを実行して、入力をコピペしてctrl+d -> 入力待ちが終了しない
while (sc.hasNext()) {
int n = Integer.parseInt(sc.next());
list.add(n);
}
解決策
"If you leave the console to focus on another view, and then refocus on the console, then Ctrl-D (EOF) works as expected."
- 「コンソールからフォーカス外して、もう一回フォーカスしてから入力したらいけるで」
- いけた