Source Code : Create BufferedReader from InputStreamReader and System.in, read console input

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Create BufferedReader from InputStreamReader and System.in, read console input

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

class Main {
  public static void main(String args[]) throws Exception {
    InputStreamReader isr = new InputStreamReader(System.in);
    BufferedReader br = new BufferedReader(isr);

    while (true) {
      System.out.print("Radius? ");
      String str = br.readLine();
      double radius;
      try {
        radius = Double.valueOf(str).doubleValue();
      } catch (NumberFormatException nfe) {
        System.out.println("Incorrect format!");
        continue;
      }
      if (radius <= 0) {
        System.out.println("Radius must be positive!");
        continue;
      }
      System.out.println("radius " + radius);
      return;
    }
  }
}

   
    
    
  

Thank with us