拉鍊我知道如何創建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中的檢查太多,無法很快完成。 –