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);
    }/*  www. jav a2s . c om*/
  }
}

Result

Related Topic