拉链我知道如何创建zip文件:如何创建与LZMA压缩
import java.io.*;
import java.util.zip.*;
public class ZipCreateExample{
public static void main(String[] args) throws Exception
// input file
FileInputStream in = new FileInputStream("F:/sometxt.txt");
// out put file
ZipOutputStream out = new ZipOutputStream(new FileOutputStream("F:/tmp.zip"));
// name the file inside the zip file
out.putNextEntry(new ZipEntry("zippedjava.txt"));
// buffer size
byte[] b = new byte[1024];
int count;
while ((count = in.read(b)) > 0) {
System.out.println();
out.write(b, 0, count);
}
out.close();
in.close();
}
}
但我不知道如何使用LZMA压缩。
我发现这个项目:https://github.com/jponge/lzma-java它创建压缩文件,但我不知道我应该如何结合它与我现有的解决方案。
无论是Java的邮编util的,也不是每一个ZipEntry的共享,压缩支持LZMA压缩。大概需要一两天的时间来扩展Commons-Compress,通过使用上面的LZMA代码来支持它并覆盖存储检查| DEFLATE。事实上,如果Commons-Compress可以使用更可扩展的方法,ZipArchiveEntries使用所需的压缩方法(例如ZipArchiveEntryLZMA)进行扩展,那将会很不错。事实上,ZipArchiveOutputStream中的检查太多,无法很快完成。 –