Reading the content of a PDS member

To read the content of a PDS member from an IPartitionedDataSetMember:

IPartitionedDataSetMember partitionedDataSetMember = ...

// create a BufferedReader wrapping a new MemberReader using a
// try-with-resource statement
try (BufferedReader reader = new BufferedReader(new MemberReader(
        partitionedDataSetMember))) {
    // read the partitioned dataset member 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 partitioned dataset
    ...
} catch (DataSetInUseException e) {
    // the partitioned dataset is enqueued by another user or job
    ...
} catch (DataSetMigratedException e) {
    // the partitioned dataset has been migrated since it was first
    // retrieved
    ...
} catch (DataSetNotFoundException e) {
    // the partitioned dataset can no longer be found
    ...
} catch (MemberNotFoundException e) {
    // the partitioned dataset member 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 PDS member using an IZOSHostConnection:

IZOSHostConnection zosHostConnection = ...
String pdsName = ...
String memberName = ...

// create a BufferedReader wrapping a new MemberReader using a
// try-with-resource statement
try (BufferedReader reader = new BufferedReader(new MemberReader(
        zosHostConnection, pdsName, memberName))) {
    // read the partitioned dataset member 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 partitioned dataset
    ...
} catch (DataSetInUseException e) {
    // the partitioned dataset is enqueued by another user or job
    ...
} catch (DataSetMigratedException e) {
    // the partitioned dataset is migrated
    ...
} catch (DataSetNotFoundException e) {
    // the partitioned dataset could not be found or is not a
    // partitioned dataset
    ...
} catch (MemberNotFoundException e) {
    // the partitioned dataset member could not be found
    ...
} 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