java.lang.Object
com.blackhillsoftware.zutil.io.RecordWriter
com.blackhillsoftware.zutil.io.TextRecordWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
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 Summary
Modifier and TypeMethodDescriptionGet the encoding used to convert the data to a Java stringboolean
Should output lines greater then the LRECL be wrapped to the next recordstatic TextRecordWriter
Construct a new TextRecordWriter using the same syntax ascom.ibm.jzos.RecordWriter.newWriter(String name, int flags)
static TextRecordWriter
newWriterForDD
(String ddname) Construct a new TextRecordWriter using the same syntax ascom.ibm.jzos.RecordWriter.newWriterForDD(String ddname)
setEncoding
(String encoding) Set the EBCDIC variant encoding used to convert the data to a Java stringsetWrapLines
(boolean wrapLines) Indicate whether lines greater than the dataset LRECL should be wrapped to the next record (default: false).void
write
(byte[] buf) TextRecordWriter does not support writing byte datavoid
write
(byte[] buf, int offset, int len) TextRecordWriter does not support writing byte datavoid
Write a string to the output dataset.Methods inherited from class com.blackhillsoftware.zutil.io.RecordWriter
close, flush, getAutoFree, getBlksize, getDDName, getDsn, getLrecl, getRecfm, getRecfmBits, setAutoFree
-
Method Details
-
newWriter
Construct a new TextRecordWriter using the same syntax ascom.ibm.jzos.RecordWriter.newWriter(String name, int flags)
- Throws:
IOException
- if the JZOS native call fails
-
newWriterForDD
Construct a new TextRecordWriter using the same syntax ascom.ibm.jzos.RecordWriter.newWriterForDD(String ddname)
- Throws:
IOException
- if the JZOS native call fails
-
setEncoding
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
Get the encoding used to convert the data to a Java string- Returns:
- String the encoding value
-
writeLine
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 ifgetWrapLines()
is true, otherwise an exception will be thrown.- Parameters:
out
- The string to be written.- Throws:
IOException
-
setWrapLines
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 classRecordWriter
-
write
public void write(byte[] buf, int offset, int len) TextRecordWriter does not support writing byte data- Overrides:
write
in classRecordWriter
-