How to read from standard input : Console Read « Development « Java Tutorial






import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class MainClass {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s;
    while ((s = in.readLine()) != null && s.length() != 0)
      System.out.println(s);
    // An empty line or Ctrl-Z terminates the program
  }
}








6.3.Console Read
6.3.1.How to read from standard input
6.3.2.Read from keyboard
6.3.3.Getting Data From the Keyboard
6.3.4.Tokenizing a Stream from console input
6.3.5.Read password from console