【发布时间】:2014-08-16 06:14:06
【问题描述】:
我尝试在 android 中像这样压缩大字符串:
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();
}
但此代码返回内存不足错误:
Base64.encodeToString(bytes, true);行中的内存不足返回
【问题讨论】:
-
你是直接用
"MyLarge String"还是用一个非常大的字符串? -
我看不出这个问题是如何与stackoverflow.com/questions/6717165/…重复的
标签: android gzipstream