• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

The End Of File Indicator doesn't work in Ubuntu?

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
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:





 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Enter 123 and it says int. Enter Campbell and it says . Enter ctrl-D and it shows a prompt.
Please provide more details of what you are doing and what goes wrong.
 
Hasan Fatih
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And are you using an IDE?
 
Hasan Fatih
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I am using Netbeans. Why did you ask me this question?
 
Marshal
Posts: 28193
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul C is right. Using an EOF character at the terminal might suggest you are becoming platform‑dependent.
 
Hasan Fatih
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thank you so much.
 
Hasan Fatih
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thank you so much.
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried that same program using Eclipse and it said, “<terminated>” after I pushed ctrl‑D. I don't usually use NetBeans.
 
Hasan Fatih
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Interesting...
 
Campbell Ritchie
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Hasan Fatih
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I understood. Thank you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic