Results 1 to 2 of 2
  1. #1
    barney is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default Help with BufferedInputstream and/or DataInputStream

    Hi, I would like to read data from the console in Java. I know that I need to use BufferedInputstream and/or DataInputStream but I need an example.

    Something like:

    Java Code:
    Int value;
    System.out.println("Please enter the percentage!");
    then the the user enters/types: 60%
    
    and then value = 60%.
    Thanks.

  2. #2
    zoe
    zoe is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default

    Please check this:
    Java Code:
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String pct = null;
    
    try{ 
        pct = br.readLine(); 
    }
    catch(IOException e){ 
        System.out.println("IO error has occurred"); 
        System.exit(1); 
    }
    
    System.out.println("You entered, " + pct);

Similar Threads

  1. DataInputStream readLine()
    By ravian in forum New To Java
    Replies: 2
    Last Post: 11-26-2007, 10:44 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •