Java: Scanner stopping at new line

前端 未结 4 2012
花落未央
花落未央 2021-01-24 11:53

I am trying to scan through text files and add them to a map, the map and everything is working. However, the scanner seems to be stopping when it comes to a \'enter\' i

4条回答
  •  萌比男神i
    2021-01-24 12:26

    Not having worked with Java in a very long time I may be way off, but it looks like you call inputText = input.nextLine(); exactly once, so it makes sense that you're only getting one line. Presumably you want to call nextLine() in a loop so that it keeps giving you lines until it gets to the end of the file.

提交回复
热议问题