- All Implemented Interfaces:
Closeable
,AutoCloseable
,Iterable<VRecord>
VRecordReader implements Closeable
and should normally be used
in a try with resources block so that it will be closed automatically:
try (VRecordReader reader = VRecordReader.fromName("//DD:INPUT"))
{
for (VRecord record : reader)
{
// process record
}
}
-
Method Summary
Modifier and TypeMethodDescriptionabstract void
close()
Close the input source.static VRecordReader
Create a new VRecordReader to read from an allocated DD.static VRecordReader
Create a new VRecordReader to read from a named file or dataset.static VRecordReader
fromStream
(InputStream stream) Create a new VRecordReader to read from an existing stream.static VRecordReader
fromStream
(InputStream stream, SmfRecordReader.RecordFormat format) Create a new VRecordReader to read from an existing stream specifying the record format.iterator()
Get an Iterator to read VRecords from the input source.abstract VRecord
read()
Read a record, returning null at end of input.abstract int
read
(byte[] buffer) Read a record into an existing array.stream()
Get a Java Stream to read VRecord from the input stream or DD.
-
Method Details
-
fromDD
Create a new VRecordReader to read from an allocated DD.Set up a a try-with-resources block to automatically close the dataset, or call
close()
when finished reading.- Parameters:
dd
- The DDNAME for the dataset. The DD must be already allocated e.g. via JCL.- Returns:
- a new VRecordReader to read from the DD
- Throws:
IOException
- if the JZOS RecordReader throws an exception
-
fromName
Create a new VRecordReader to read from a named file or dataset. Names can take several forms:- If the name begins with "//DD:" the VRecordReader will open and read from
the preallocated DD name.
"//DD:INPUT"
- If the name begins with with "//" but not "///" the VRecordReader will
open and read from a 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 VRecordReader will open a FileInputStream using that name (typically reading from a Windows/Linux/HFS etc. file).
Set up a a try-with-resources block to automatically close the input source, or call
close()
when finished reading.- Parameters:
name
- The name of the resource to open, in the formats documented above.- Returns:
- a new VRecordReader
- Throws:
IOException
- if the JZOS RecordReader or FileInputStream throws an exceptionFileNotFoundException
- if the FileInputStream cannot find the file
- If the name begins with "//DD:" the VRecordReader will open and read from
the preallocated DD name.
-
fromStream
Create a new VRecordReader to read from an existing stream.The stream must contain complete variable length records, including the RDW
Set up a a try-with-resources block to automatically close the stream, or call
close()
when finished reading.- Parameters:
stream
- the InputStream to read.- Returns:
- a new VRecordReader to read from the stream
-
fromStream
Create a new VRecordReader to read from an existing stream specifying the record format.The stream must contain complete variable length records, including the RDW, and the BDW if RecordFormat.U is specified
RecordFormat.AUTODETECT is only supported by SmfRecordReader for SMF data.
Set up a a try-with-resources block to automatically close the stream, or call
close()
when finished reading.- Parameters:
stream
- the InputStream to read.format
- theSmfRecordReader.RecordFormat
of the records in the stream - U, V or AutoDetect- Returns:
- a new VRecordReader to read from the stream
-
close
Close the input source.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
- if an I/O error occurs
-
read
Read a record, returning null at end of input.- Returns:
- a VRecord or null
- Throws:
IOException
- if an I/O error occurs
-
read
Read a record into an existing array.- Returns:
- the number of bytes read, -1 at end of input.
- Throws:
IOException
- if an I/O error occurs
-
iterator
Get an Iterator to read VRecords from the input source. -
spliterator
- Specified by:
spliterator
in interfaceIterable<VRecord>
-
stream
Get a Java Stream to read VRecord from the input stream or DD.- Returns:
- Stream<VRecord>
- See Also:
-