Java - Read text from console

Description

Read text from console

Demo

public class EchoText {
  public static void main(String[] args) throws java.io.IOException {
    System.out.println("Please enter some text and press Enter!");
    int ch;/*  w w  w.j a v  a2s .com*/
    while ((ch = System.in.read()) != -1)
      System.out.print((char) ch);
    System.out.println();
  }
}

Related Topic