I try to compressed large string in android Like this:
try {
String str = "MyLarge String";
ByteArrayOutputStream rstBao = new ByteArrayOutputStream(str.length());
GZIPOutputStream zos = new GZIPOutputStream(rstBao);
zos.write(str.getBytes());
IOUtils.closeQuietly(zos);
byte[] bytes = rstBao.toByteArray();
String compressedString = Base64.encodeToString(bytes, true);
Log.i("Compressed", compressedString);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
but this code return outofmemory error:
outofmemory return in
Base64.encodeToString(bytes, true);
line