Module com.blackhillsoftware.zutil
Package com.blackhillsoftware.zutil.io
package com.blackhillsoftware.zutil.io
This package provides classes to simplify working with z/OS datasets.
RecordReader and RecordWriter
RecordReader
and
RecordWriter
are wrappers for
com.ibm.jzos.RecordReader
and
com.ibm.jzos.RecordWriter
which add the Closeable
interface and
so can be used with try-with-resources blocks.
This simplifies the code to read/write z/OS datasets. Instead of:
RecordReader reader = null; try { reader = RecordReader.newReaderForDD("INPUT"); // read records } finally { if (reader != null) { reader.close(); } }
you can use:
try (RecordReader reader = RecordReader.newReaderForDD("INPUT")) { // read records }for the same result.
TextRecordReader and TextRecordWriter
TextRecordReader
and
TextRecordWriter
provide the ability to read and write Strings from EBCDIC text datasets.
They attempt to provide similar semantics to reading and writing Strings to a regular file. You can:
- Read a dataset line by line:
TextRecordReader.readLine()
- Read all lines into a List of Strings:
TextRecordReader.readAllLines()
- Write a String to a dataset:
TextRecordWriter.writeLine(String)
.
If the String contains newline characters it will be split into multiple records.TextRecordWriter.setWrapLines(boolean)
controls whether a String that is too long to fit in a record will be wrapped to the next record or throw an exception.
-
ClassesClassDescriptionThis class wraps
com.ibm.jzos.RecordReader
and implementsjava.io.Closeable
, allowing you to use the RecordReader with a try-with-resources block.This class wrapscom.ibm.jzos.RecordWriter
and implementsjava.io.Closeable
, allowing you to use the RecordWriter with a try-with-resources block.A program to test the classes on z/OS.Class to read records from z/OS datasets as Strings.Class to write records to z/OS datasets as Strings.Call IBM JZOSZFile
methods without a compile time dependency on the JZOS jar.