我使用XZ格式压缩了一个大小为85MB的SQLite数据库文件,并将其压缩到16MB。 在Android Jelly Bean中,我使用以下代码(以及由XZ for Java提供的JAR)进行解压:
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。
我想知道我是否在代码中做错了什么或者是否有方法可以加快解压速度。