2010-08-13 39 views
1

上述文件擴展名在這裏解釋爲http://kb.iu.edu/data/abck.html。我想用java api來讀取Z文件的內容。 ZipFile api或GZIPInputStream似乎都不起作用。我可以使用ZipFile API來打開普通的.zip文件。用Java讀取.Z文件(unix壓縮文件)

ZipFile zf = new ZipFile("CR93H2.Z"); 
Enumeration entries = zf.entries(); 

要添加,所述.Z文件在winrar中打開罰款。

有誰知道它的解決方案。

感謝

+1

請參閱[我需要使用java提取.tar.Z文件](http://stackoverflow.com/q/15039566/309483) – 2013-06-25 19:28:17

回答

1

您可以使用 compress-j2me

% svn checkout --quiet http://compress-j2me.googlecode.com/svn/trunk/ compj2me 
% cd compj2me/src/lzc-test 
% ant -q 
% cd build/cmd 
% echo "testdonkeyballs" | compress | java com.googlecode.compress_j2me.lzc.Main -d 
testdonkeyballs 
0

我已經成功讀取與UncompressInputStream.java壓縮文件。我沒有驗證邏輯是否正確,但它似乎工作。

FileInputStream fis = new FileInputStream(new File("thefile.cfg.Z")); 
    InputStream is = new UncompressInputStream(new BufferedInputStream(fis)); 
    BufferedReader reader = new BufferedReader(new InputStreamReader(is)); 
    String line = null; 
    while ((line = reader.readLine()) != null) 
    { 
     System.out.println("line = " + line); 
    }