This discussion is archived
1 Reply Latest reply: Nov 20, 2009 11:45 AM by 807580 RSS

reg IOException

807580 Newbie
Currently Being Moderated
In my program, I am performing addition of all numbers entered by user at command prompt, I am using Buffered reader to read the input, the program works fine for small data entered but when I past the large amount of data for example around 20 lines each having 4 digits seperated by space I get below exception:

Exception in thread "main" Not enough storage is available to process this command
at Method)
at sun.nio.cs.StreamDecoder$CharsetSD.readBytes(
at sun.nio.cs.StreamDecoder$CharsetSD.implRead(
at MainIO.main(

Interestingly, if instead of pasting all 20 rows at once if I past 10 rows twice I get output without any exception. Any thoughts whats going on??
                    BufferedReader bufferReader = new BufferedReader(new InputStreamReader(;     
                       int Sum=0;
                                 //number of rows of input
                    int num = Integer.parseInt(bufferReader.readLine());     
                              for(int k=0;k<num;k++){
                                        String[] row = bufferReader.readLine().split(" ");
                                        for(int l=0;l<row.length;l++){
                                             Sum = Sum+Integer.parseInt(row[l]);
Edited by: RashmiPatel on Nov 20, 2009 11:39 AM