Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

When does Java allow console input?

 
Ryan Smith
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's my code:


First, what triggers a "pause" in program execution?
Secondly, is my code alright?

Thanks so much.

[ June 29, 2004: Message edited by: Ryan Smith ]
[ June 29, 2004: Message edited by: Ryan Smith ]
 
Sandeep Jindal
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ryan,

I have seen your code. You are using a class EasyReader for getting the input from console. You have not send this file. If this file is working as per your requiremnts, your code is working fine.

Answer to your first question, to pause a program execution/getting input from console, we have make instance of input stream reader passing System.in to get input from console.

Hope this will clear your doubt.

Sandeep
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This code might be helpful for to learn about the I/O... Make sure you understand the concept of I/O technique...

 
Ryan Smith
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys, thanks so much...that worked!! But, I'm kind of curious now how IO streams work...I didn't quite follow. First, you create an instance of an InputStreamReader, which takes System.in as an argument - does this just create an InputStreamReader that reads console input?

Then, you pass the isr to the BufferedReader - is the bufferedReader just a way of storing isr's data?

That is all a guess, so please correct me...

On a side note, is anyone here studying from a Java book...I'm using JAVA Methods, which is a little on the toned-down side. Kind of slow...

Thanks again guys!
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Ryan, what you understand is correct... I'm glad to hear that your problem is solved and don't forget to help others as well...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic