Java - Read data entered using the keyboard.

Description

Read data entered using the keyboard.

Demo

import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    // Prompt the user to type a message
    System.out.print("Please type a message and press enter: ");

    // Display whatever user types in
    int c = '\n';
    while ((c = System.in.read()) != '\n') {
      System.out.print((char) c);
    }/*from ww  w .j  av  a 2 s.com*/
  }
}

Result

Related Topic