Read a .Z file (unix compresses file) in Java

后端 未结 2 1824
我在风中等你
我在风中等你 2020-12-12 02:57

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 GZIPI

相关标签:
2条回答
  • 2020-12-12 03:27

    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.

    0 讨论(0)
  • 2020-12-12 03:34

    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 );
        }
    
    0 讨论(0)
提交回复
热议问题