java.lang.Object
com.blackhillsoftware.smf.SmfRecordWriter
- All Implemented Interfaces:
Closeable
,AutoCloseable
SmfRecordWriter writes SMF records to a DD statement allocated to the job, or an OutputStream.
SmfRecordWriter implements Closeable and so should be used with try with resources so that it will
be closed automatically:
try (SmfRecordWriter writer = SmfRecordWriter.fromName("//DD:OUTPUT"))
{
...
writer.write(smfrecord);
}
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close the output dataset or stream.static SmfRecordWriter
Create a new SmfRecordWriter to write to an allocated DD.static SmfRecordWriter
Create a new SmfRecordWriter to write to a named file or dataset.static SmfRecordWriter
fromStream
(OutputStream stream) Create a new SmfRecordWriter to write to an existing stream.void
-
Method Details
-
fromDD
Create a new SmfRecordWriter to write to an allocated DD.- Parameters:
dd
- The DDNAME for the SMF output data. The DD must be already allocated e.g. via JCL.- Returns:
- a new SmfRecordReader to write to the DD
- Throws:
IOException
- if an I/O error occurs
-
fromStream
Create a new SmfRecordWriter to write to an existing stream.Records written to the stream will include the RDW
- Parameters:
stream
- the OutputStream to write records to.- Returns:
- a new SmfRecordWriter to write to the stream
-
fromName
Create a new SmfRecordWriter to write to a named file or dataset. Names can take several forms:- If the name begins with "//DD:" the SmfRecordWriter will open and write to
the preallocated DD name.
"//DD:INPUT"
- If the name begins with with "//" but not "///" the SmfRecordWriter will
open and write to an existing MVS dataset using the same syntax as the C fopen() function.
Use single quotes to specify the complete dataset name, otherwise the
user's prefix is added.
"//'MVS.DATASET.NAME'" "//'MVS.DATASET.NAME(0)'"
- Otherwise the SmfRecordWriter will open a FileOutputStream using that name (typically writing to a Windows/Linux/HFS etc. file).
The writer can be automatically closed using a try-with-resources block (recommended), or call
close()
when finished writing.- Parameters:
name
- The name of the resource to open, in one of the formats documented above.- Returns:
- a new SmfRecordWriter
- Throws:
IOException
- if an I/O error occursFileNotFoundException
- if the file is not found
- If the name begins with "//DD:" the SmfRecordWriter will open and write to
the preallocated DD name.
-
close
Close the output dataset or stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs
-
write
- Throws:
IOException
-