I've learned from my book that the end of file indicator for linux systems is CTRL + D. But when I tried to CTRL + D combination, then enter, the program didn't stop. It still continued. How can I handle this problem? I'm using Netbeans on Ubuntu. Here are the codes:
Where are you using ctrl‑D? You do not usually use it when you are using a Scanner. I went through the API for System.in, well more precisely an InputStream, and couldn't see anything about ctrl‑D or other file end characters. I shall try it out and report what happens.
I have had to edit your post because the lines are too long, and noticed you used \n. You should only ever use \n or \r if somebody has specified CR and LF characters. Since you were using printf, you should change the \n to %n
I was just trying to enter input into the file. Then I was expecting to close file and BUILDING SUCCESSFULL notification in the output with CTRL+D. Because with CTRL+D, the program should exit from the while loop in the addRecords(), so the addRecords method should have finished, and finally the closeFile method should have been executed. Thereby the program should have finished properly. But the program doesn't finish. Just go ahead in the while loop. Why?
As far as I understand from my book that the loop terminates with CTRL + Z combination in windows and CTRL + D combination in linux/unix/mac os x.
The Ctrl-Z character is used in the Windows shell, and Ctrl-D in the Unix shell, to indicate the end of the input. But if you're using an IDE and running your code inside it, then you aren't using either of those shells and therefore the Ctrl-Z and Ctrl-D information is probably irrelevant.
And what you wrote there describing how things work tends to support the idea that you have to know what character your IDE is expecting to indicate the end of the input, if indeed it even supports such a character.
Maybe interesting, but I don't think we shall get to the bottom of the difference that simply. I don't usually use NetBeans.
I'll try duplicating this discussion in our IDEs forum but I suspect nobody will know any more there. You could try asking on a specific NetBeans forum and if you do, be sure to mention this discussion first, and do tell us if you find anything out.