This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes How to input End of File indicator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to input End of File indicator" Watch "How to input End of File indicator" New topic
Author

How to input End of File indicator

John Eipe
Ranch Hand

Joined: May 23, 2008
Posts: 215
Hello,

I read in a book that end of file could be given as input for a program. For Windows, it's <Ctrl> + Z.
But it never works.

This is the code i tried to work on:



Please let me know if I need to post the full program.


www.cs-repository.info
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
That looks like something out of chapter 14 of the Deitel book.
C:\JavaPrograms\DeitelCh14>edit Eipe.java

C:\JavaPrograms\DeitelCh14>javac Eipe.java

C:\JavaPrograms\DeitelCh14>java Eipe
Campbell
Campbell
Ritchie
Ritchie
^Z

C:\JavaPrograms\DeitelCh14>
You see I am, unusually, running Windows, and the program turned off when I used ctrl-Z. Please provide more details about what goes wrong.
John Eipe
Ranch Hand

Joined: May 23, 2008
Posts: 215
I'm running it from NetBeans IDE. Is that the reason, it doesn't work?

John Eipe
John Eipe
Ranch Hand

Joined: May 23, 2008
Posts: 215
I tried it from command line and it works! What should I do in Net Beans?

John Eipe
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Don't know, I am afraid.
salvin francis
Ranch Hand

Joined: Jan 12, 2009
Posts: 928

I have worked on Netbeans

See, Editors like netbeans have an inbuild prompt that emulate the command prompt of the OS,
However, these should not be seens as a benchmark for your system.
usually editors now a days have limited support for text input via thier console.

if you do want to have an interactive user input in a CUI interface,
run the program via the os command prompt.

The problem is that now a days CUI is obsolete, you can prepare a GUI in a matter of seconds that does the same job in a more pleasing way.


My Website: [Salvin.in] Cool your mind:[Salvin.in/painting] My Sally:[Salvin.in/sally]
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Note that Eclipse allows this magic to happen


[My Blog]
All roads lead to JavaRanch
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to input End of File indicator