Class TextRecordWriter

java.lang.Object
com.blackhillsoftware.zutil.io.RecordWriter
com.blackhillsoftware.zutil.io.TextRecordWriter
All Implemented Interfaces:
Closeable, AutoCloseable

public class TextRecordWriter extends RecordWriter implements Closeable
Class to write records to z/OS datasets as Strings. Uses the com.ibm.jzos.RecordWriter class to read the data and com.ibm.jzos.fields.StringField to convert the records from Strings.
  • Method Details

    • newWriter

      public static TextRecordWriter newWriter(String name, int flags) throws IOException
      Construct a new TextRecordWriter using the same syntax as com.ibm.jzos.RecordWriter.newWriter(String name, int flags)
      Throws:
      IOException - if the JZOS native call fails
    • newWriterForDD

      public static TextRecordWriter newWriterForDD(String ddname) throws IOException
      Construct a new TextRecordWriter using the same syntax as com.ibm.jzos.RecordWriter.newWriterForDD(String ddname)
      Throws:
      IOException - if the JZOS native call fails
    • setEncoding

      public TextRecordWriter setEncoding(String encoding)
      Set the EBCDIC variant encoding used to convert the data to a Java string
      Parameters:
      encoding - the EBCDIC encoding e.g. "Cp1047"
      Returns:
      this TextRecordWriter to allow fluent style usage
    • getEncoding

      public String getEncoding()
      Get the encoding used to convert the data to a Java string
      Returns:
      String the encoding value
    • writeLine

      public void writeLine(String out) throws IOException
      Write a string to the output dataset. The string will be converted to EBCDIC according to the specified or default encoding. The string can contain new line characters. If newlines are present the string will be split and multiple records will be written. If a line (or the whole string, if it does not contain newlines) is greater than the LRECL, the line will wrap to the next record if getWrapLines() is true, otherwise an exception will be thrown.
      Parameters:
      out - The string to be written.
      Throws:
      IOException
    • setWrapLines

      public TextRecordWriter setWrapLines(boolean wrapLines)
      Indicate whether lines greater than the dataset LRECL should be wrapped to the next record (default: false). If false, long lines will throw an exception.
      Parameters:
      wrapLines - true if long lines should wrap to the next record.
      Returns:
      this TextRecordWriter to allow fluent style usage
    • getWrapLines

      public boolean getWrapLines()
      Should output lines greater then the LRECL be wrapped to the next record
      Returns:
      true if lines should be wrapped
    • write

      public void write(byte[] buf)
      TextRecordWriter does not support writing byte data
      Overrides:
      write in class RecordWriter
    • write

      public void write(byte[] buf, int offset, int len)
      TextRecordWriter does not support writing byte data
      Overrides:
      write in class RecordWriter