import java.awt.*;
// Need this import for reading data:
import java.io.*;

// reading data in a Java application
public class ReadingLine {

    public static void main (String [] args) throws IOException {
	// Create a buffered reader
	BufferedReader in = new BufferedReader(
			new InputStreamReader(System.in));
	// string for storing a line of input
	String line;

	// prompt the user:
	System.out.print("Please say something: ");
	// read the line:
	line = in.readLine();
	// print it back:
	System.out.println("You said: " + line);
	// prompt the user again:
	System.out.print("Keep on talking: ");
	// read another line:
	line = in.readLine();
	// print it back:
	System.out.println("You also said: " + line);
    }

}

This is an example from CSci 1211 course.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.