Module ibm.jzos
Package com.ibm.jzos

Class ZCompressorInputStream

All Implemented Interfaces:
Closeable, AutoCloseable

public class ZCompressorInputStream extends FilterInputStream implements AutoCloseable
A subclass of InputStream that will expand data from an enclosed InputStream containing data that was compressed by the same z/Architecture compression dictionaries. Not thread safe. The class implements AutoCloseable. It can be used with the AutoCloseable with a try-with-resources block or without, as shown in the two examples below: Example 1: Allocate and close a ZFile when a try-with-resources block is not used. The an explicit call to the close() close the ZFile object and release the associated resources. The close() method is called in a finally block to assure that the close is performed after the try block completes.

    ZFile zfile = new  new ZFile(fileName, options);
    try {
        byte[] recBuf = new byte[lrecl];
        // read the records sequentially
        while (zfile.read(recBuf) != -1) {
            String record = new String(recBuf);
            System.out.println("Record=" + record);
        }
    }
    finally {
      zfile.close();
    }
   
Example 2: Allocate a ZFile when a try-with-resources block is used. The method close() is not needed. Upon exiting a try-with-resources block, the AutoCloseable will automatically call the close() method which will lose the ZFile object and release the associated resources.

    try (ZFile zfile = new  new ZFile(fileName, options)) {
        byte[] recBuf = new byte[lrecl];
        // read the records sequentially
        while (zfile.read(recBuf) != -1) {
            String record = new String(recBuf);
            System.out.println("Record=" + record);
        }
    }
    ...
   
Since:
2.4.4
See Also: