arrays - Java use 1 billion digits of pi -


i trying make program search first 1 billion digits of pi , find user specified number, problem facing how use pi... have .txt file contains pi (i broke 96 different files because java couldn't handle such big file) digits in first line.... code (only read , save pi using 96 files):

for(int = 1;i <= 96; i++){         string filename = "";         if(i <= 9){             filename = "res//t//output2_00000" + + "(500001).txt";         }else{             filename = "res//t//output2_0000" + + "(500001).txt";         }         scanner infile = new scanner(new filereader(filename));         ar.add(infile.nextline());     }     list<string> pi = new arraylist<string>();     for(int = 0; i<97;i++){         system.out.println(i);         for(string j : ar.get(i).split("")){             pi.add(j);         }     } 

this seems work fine point crashes following error (the last print statement 3):

exception in thread "main" java.lang.outofmemoryerror: java heap space @ java.lang.string.substring(unknown source) @ java.lang.string.subsequence(unknown source) @ java.util.regex.pattern.split(unknown source) @ java.lang.string.split(unknown source) @ java.lang.string.split(unknown source) @ main.main.main(main.java:29) 

is there way overcome that, , there way make go faster? in advance.

it go out of heap memory if try load on 1gb of data heap. check every single file search string , close file.


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -