Reading the content of a sequential data set

To read the content of a sequential data set from an ISequentialDataSet:

ISequentialDataSet sequentialDataSet = ...

// create a BufferedReader wrapping a new DataSetReader using a
// try-with-resources statement
try (BufferedReader reader = new BufferedReader(new DataSetReader(
        sequentialDataSet))) {
    // read the sequential dataset data using the reader
    String record;
    while ((record = reader.readLine()) != null) {
        // note: non-displayable characters will be output as the
        // '\uFFFD' (lozenge) character (displays as '?' in some
        // character sets)
        System.out.println(record);
    }
} catch (DataSetAccessException e) {
    // the user does not have access to the sequential dataset
    ...
} catch (DataSetInUseException e) {
    // the sequential dataset is enqueued by another user or job
    ...
} catch (DataSetMigratedException e) {
    // the sequential dataset has been migrated since it was first
    // retrieved
    ...
} catch (DataSetNotFoundException e) {
    // the sequential dataset can no longer be found
    ...
} catch (IOException e) {
    // an IO error has occurred reading a line and/or closing the reader
    ...
}

To read the content of a sequential data set using an IZOSHostConnection:

IZOSHostConnection zosHostConnection = ...
String sequentialDataSetName = ...

// create a BufferedReader wrapping a new DataSetReader using a
// try-with-resource statement
try (BufferedReader reader = new BufferedReader(new DataSetReader(
        zosHostConnection, sequentialDataSetName))) {
    // read the sequential dataset data using the reader
    String record;
    while ((record = reader.readLine()) != null) {
        // note: non-displayable characters will be output as the
        // '\uFFFD' (lozenge) character (displays as '?' in some
        // character sets)
        System.out.println(record);
    }
} catch (DataSetAccessException e) {
    // the user does not have access to the sequential dataset
    ...
} catch (DataSetInUseException e) {
    // the sequential dataset is enqueued by another user or job
    ...
} catch (DataSetMigratedException e) {
    // the sequential dataset is migrated
    ...
} catch (DataSetNotFoundException e) {
    // the sequential dataset could not be found or is not a sequential
    // dataset
    ...
} catch (IOException e) {
    // an IO error has occurred reading a line and/or closing the reader
    ...
}
Was this page helpful? Yes No Submitting... Thank you

Comments