BufferedReader readLine() issue: detecting end of file and empty return lines

后端 未结 5 1361
粉色の甜心
粉色の甜心 2021-01-18 09:14

I want my program to do something when it finds the end of a file (EOF) at the end of the last line of text, and something else when the EOF is at the empty line AFTER that

5条回答
  •  遥遥无期
    2021-01-18 09:49

    You'll have to use read rather than readLine and handle end-of-line detection yourself. readLine considers \n, \r, and EOF all to be line terminators, and doesn't include the terminator in what it returns, so you can't differentiate on the basis of the returned string.

提交回复
热议问题