I have developed an android application which will consume a large data in a zipped format. i used to unzip it and when i parse the unzipped file it shows outofmemory error since the Heap size increased to 125MB. I am using apache commons.io to fetch byte[] b and i am giving String s =new String(b);I tried Stringbuilder but i cant get that logic in place. Is there any other way to safely convert byte[] to String in android?
Asked
Active
Viewed 344 times
2
-
2Don't forgot you are dealing with the mobile..... – Pragnani Feb 12 '13 at 18:39
1 Answers
6
There isn't a way to convert that much data at once (125MB) to a string. You're better off doing this in incremental steps in more mangeable chunks.

hwrdprkns
- 7,525
- 12
- 48
- 69
-
Ya how to divide the byte[] into chunks and collect it in a string?\ – Anand Asir Feb 13 '13 at 02:18
-
Well, usually a character is a byte, so just parse each byte for the resulting string. More information here: http://stackoverflow.com/a/4850316/354247 – hwrdprkns Feb 13 '13 at 04:24
-
If this answered your question, think about accepting it for the benefit of future users. – hwrdprkns Feb 14 '13 at 00:20