Writing to a sequential data set


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

ISequentialDataSet sequentialDataSet = ...
datasetContents = ...

// create a BufferedWriter wrapping a new DataSetReader using a
// try-with-resources statement
try (BufferedWriter writer = new BufferedWriter(new DataSetWriter(
        sequentialDataSet))) {
   // write the sequential dataset data using the writer
    writer.write(datasetContents);
} 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 writing the sequential dataset and/or closing the writer
    ...
}

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

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

// create a BufferedWriter wrapping a new DataSetWriter using a
// try-with-resource statement
try (BufferedWriter writer = new BufferedWriter(new DataSetWriter(
        zosHostConnection, sequentialDataSetName))) {
   // write the sequential dataset data using the writer
    writer.write(datasetContents);
} 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 writing the sequential dataset closing the writer
    ...
}

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*