A feature of the operating system.
import java.util.Scanner;
class Echo
{
public static void main ( String[] args )
{
Scanner scan = new Scanner( System.in );
String line;
System.out.println("Enter your input:");
line = scan.nextLine();
System.out.println( "You typed: " + line );
}
}
You can write a program to use any type of file as input, but this chapter only discusses input from text files. This example program that reads input from the keyboard. Here (again) is how it ordinarily works:
C:\temp>java Echo Enter your input: This came from the keyboard You typed: This came from the keyboard D:\users\default\JavaLessons>
How many lines of text does the program read?