Reading Text from Standard Input : System « Development Class « Java






Reading Text from Standard Input

      

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

public class Main {
  public static void main(String[] argv) throws Exception {

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String str = "";
    while (str != null) {
      System.out.print("> prompt ");
      str = in.readLine();
      System.out.println(str);
    }
  }
}

   
    
    
    
    
    
  








Related examples in the same category

1.Terminate a Java application
2.Exiting a Java program
3.Terminate virtual machine using System class
4.Run object finalization using System class
5.Run the garbage collector using System class
6.Get file separator using System class
7.System Level Utils
8.Utilities relating to the version of Java in use at runtime
9.System IO Redirect
10.Helpers for java.lang.System
11.Methods to aid classes recover from OutOfMemoryErrors by denying or reducing service rather than a complete shutdown of the JVM.
12.A window that displays the bytes sent to System.out and System.err
13.This program runs the Sieve of Erathostenes benchmarkThis program runs the Sieve of Erathostenes benchmark