Issue
I am trying to read an assets file using InputStream but it throws OutOfMemory Exception , the size of file is 22 mb ( about 22 Million Bytes ! )
This is the code I use
try{
java.io.InputStream is = MainActivity.this.getAssets().open("file.json");
int Si = is.available();
byte[] Bu = new byte[Si];
is.read(Bu);
is.close();
data = new String(Bu, "UTF-8");
}catch(Exception e){
}
Solution
As @CommonsWare said , just I have to use this
((java.io.Reader)(new java.io.InputStreamReader(ContextOfClass.getAssests().open("file name"))))
In my gson json to listmap/liststring/etc code
Answered By - Arab Ware
Answer Checked By - Gilberto Lyons (JavaFixing Admin)