在Java中读取.Z文件(unix压缩文件)

发布于 2024-09-13 19:25:00 字数 390 浏览 4 评论 0原文

上述文件扩展名的解释见 http://kb.iu.edu/data/abck。 html。我想使用 java api 读取 Z 文件的内容。 ZipFile api 或 GZIPInputStream 似乎都不起作用。我可以使用 ZipFile api 打开普通的 .zip 文件。

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

补充一下,上述 .Z 文件在 winrar 中可以正常打开。

有谁知道它的解决方案。

谢谢

The said file extension is explained here at http://kb.iu.edu/data/abck.html. I want to use a java api to read the contents of a Z file. Neither the ZipFile api or the GZIPInputStream seem to work. I can use the ZipFile api to open normal .zip files.

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

To add, the said .Z file opens up fine in winrar.

Does anyone know about the solution to it.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时常饿 2024-09-20 19:25:00

您可以使用 compress-j2me:

% git clone https://github.com/igorgatis/compress-j2me.git
% cd compress-j2me/src/lzc-test
% ant -q
% cd build/cmd
% echo "testdonkeyballs" | compress | java com.googlecode.compress_j2me.lzc.Main -d
testdonkeyballs

对于维护的替代方案,请尝试 Apache Commons-压缩

You can use compress-j2me:

% git clone https://github.com/igorgatis/compress-j2me.git
% cd compress-j2me/src/lzc-test
% ant -q
% cd build/cmd
% echo "testdonkeyballs" | compress | java com.googlecode.compress_j2me.lzc.Main -d
testdonkeyballs

For a maintained alternative, try Apache Commons-Compress.

趁微风不噪 2024-09-20 19:25:00

我已成功使用 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 );
    }

I've had success reading compressed files with UncompressInputStream.java. I haven't verified if the logic is correct, but it seems to work.

    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 );
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文