Results 1 to 4 of 4
  1. #1
    irnie1994 is offline Member
    Join Date
    Aug 2011
    Posts
    28
    Rep Power
    0

    Question How to make a Java Program that can read a int using BufferedReader?


    HI! who can help me in JCREATOR??
    I need to have a sample of codes that using bufferedreader that can read integer or a number
    Thanks A LOT GUYS!!

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    Google your friend. Otherwise, show your attempt and we will help you.

  3. #3
    irnie1994 is offline Member
    Join Date
    Aug 2011
    Posts
    28
    Rep Power
    0

    Default

    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.util.*;
    import java.util.Scanner;

    public class Sample{

    public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int num = in.nextInt();
    int n = Integer.parseInt(System.console().readLine());
    String input = null;
    int number = 0;
    try {
    BufferedReader bufferedReader = new BufferedReader (new InputStreamReader(System.in));
    input = bufferedReader.readLine();
    number = Integer.parseInt(input);
    } catch (NumberFormatException ex) {
    System.out.println("Not a number !");
    } catch (IOException e) {
    e.printStackTrace();
    }
    }

    }
    no run T_T i dont know what is wrong...

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,319
    Rep Power
    25

    Default

    i dont know what is wrong
    Do you get any error messages when you try to compile your program? Please copy and paste them here.
    Do you get any error messages when you try to execute your program? Please copy and paste them here

Similar Threads

  1. Replies: 4
    Last Post: 07-23-2011, 08:08 PM
  2. Replies: 11
    Last Post: 07-19-2011, 11:39 PM
  3. How to make Java program run in the background?
    By divs1210 in forum Advanced Java
    Replies: 7
    Last Post: 04-16-2011, 05:30 PM
  4. cannot find symbol using BufferedReader.read()
    By mrs_sheep in forum Networking
    Replies: 4
    Last Post: 04-09-2010, 07:09 PM
  5. how can i make bufferedreader
    By chyeeqi in forum New To Java
    Replies: 4
    Last Post: 08-21-2009, 05:24 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
  •