【发布时间】:2014-03-15 09:10:25
【问题描述】:
大小为 85MB 的我的 SQLite db 文件使用 XZ 格式压缩,其大小已减少到 16MB。我使用下面的代码(以及XZ for Java提供的一个JAR)在Android Jelly Bean中解压:
try {
FileInputStream fin = new FileInputStream(path + "myFile.xz");
BufferedInputStream in = new BufferedInputStream(fin);
FileOutputStream out = new FileOutputStream(des + "myDecompressed");
XZInputStream xzIn = new XZInputStream(in);
final byte[] buffer = new byte[8192];
int n = 0;
while (-1 != (n = xzIn.read(buffer))) {
out.write(buffer, 0, n);
}
out.close();
xzIn.close();
}
catch(Exception e) {
Log.e("Decompress", "unzip", e);
}
解压成功,但需要两分钟多才能完成。我认为这很长,因为压缩文件只有 16MB,未压缩文件只有 85MB。
不知道是不是我的代码做错了,或者有什么办法可以加快这个解压过程。
【问题讨论】:
-
这个怎么样:sqlite.org/fts3.html,见压缩选项
-
哦,我忘了我的 sqlite db 已经很紧凑了。
-
所以你的意思是它已经被压缩了?即使 xz 将其缩短到原始大小的 20%?
-
我的意思是我的 sqlite 数据库已经很紧凑了(比如使用紧凑型数据库,Firefox SQLite 管理器)。在此之后,XZ 进行了良好的压缩。
-
不。我的数据库是保存在 sdcard 上的外部数据库。我对 XZ 很满意,所以我想去。
标签: java android compression zip xz