go to previous page   go to home page   go to next page highlighting

Answer:

Scanner has been used with the standard input stream:

Scanner scan = new Scanner( System.in );

The previous chapter showed how to use input redirection to connect System.in to a disk file.


I/O Streams

input characters converted to internal numbers

Recall, from chapter 12, that input and output are done with streams of data. There is a standard input stream, a standard output stream, and a standard error stream.

A Scanner object constructed with System.in scans the standard input stream for groups of characters. The groups can be characters separated by spaces or complete lines of text.

A group of characters separated by spaces is called a token. By default, tokens are surrounded (delimited) by spaces, tabs, or the beginning and ends of lines.

Some Scanner methods convert a token into a specific data type. For example, the nextInt() method reads in a group of characters that can be converted to an int.


QUESTION 2:

Could the characters of an input stream come from a disk file?


go to previous page   go to home page   go to next page