Class ZipDatasets


  • public class ZipDatasets
    extends java.lang.Object
    A sample Java main class that can be invoked to create a Zip archive from one or more datasets or PDS members. Datasets are treated as text and converted from EBCDIC to ASCII (ISO8859-1) or to the specified target codepage.

    Details on the input arguments to this class are available by executing the main method with no arguments. (see usage())

    Example: Zip several partitioned datasets to a Unix zip file:

    com.ibm.jzos.sample.ZipDatasets test.zip sys1.proclib(asm*) hlq.**.jcl 

    Example: Zip all datasets matching two patterns to a dataset:

    com.ibm.jzos.sample.ZipDatasets //hlq.backup.zip payroll.*.data gl.**.dat*

    Example: Zip data using DDs and input and output:

    com.ibm.jzos.sample.ZipDatasets //DD:ZIPOUT //DD:INSEQ1 //DD:INPDS1 //DD:INPDS2(FOO*)

    Since:
    2.3.0
    See Also:
    ZFile, ZUtil, CatalogSearch, java.util.zip.ZipOutputStream, java.util.regex.Pattern, java.util.regex.Matcher, ZipDatasetSource (the class which creates Zip archive entries for each input dataset/pattern)
    • Constructor Summary

      Constructors 
      Constructor Description
      ZipDatasets​(java.lang.String outFileName, java.lang.String[] indsnames)
      Construct an instance
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void main​(java.lang.String[] args)
      A Java main method for invoking this class.
      int run()
      Process the given input datasets and create a Zip archive on the given output file or dataset.
      void setTargetEncoding​(java.lang.String targetEncoding)
      Sets the name of the codepage used to encode the text data written to the Zip file.
      static void usage()
      Display usage syntax for invoking this class as a java main() method.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • DEFAULT_TARGET_ENCODING

        public static final java.lang.String DEFAULT_TARGET_ENCODING
        See Also:
        Constant Field Values
    • Constructor Detail

      • ZipDatasets

        public ZipDatasets​(java.lang.String outFileName,
                           java.lang.String[] indsnames)
        Construct an instance
        Parameters:
        outFileName - the name of the /output/file, //DATASET, //DD:name, etc where the Zip archive is written.
        indsnames - an array of input dataset names / patterns
        See Also:
        for more details on allowed input dataset names
    • Method Detail

      • usage

        public static void usage()
        Display usage syntax for invoking this class as a java main() method.
      • main

        public static void main​(java.lang.String[] args)
                         throws java.lang.Exception
        A Java main method for invoking this class.
        Parameters:
        args -
        Throws:
        java.lang.Exception
        See Also:
        usage()
      • setTargetEncoding

        public void setTargetEncoding​(java.lang.String targetEncoding)
        Sets the name of the codepage used to encode the text data written to the Zip file. If not called, defaults to DEFAULT_TARGET_ENCODING.
        Parameters:
        targetEncoding -
      • run

        public int run()
                throws java.io.IOException
        Process the given input datasets and create a Zip archive on the given output file or dataset.
        Throws:
        java.io.IOException