The LineDataRecordWriter class writes the record data, in line data format, to an OutputStream. The class translates the data into bytes by using the specified CCSID. The record format associated with the record determines the format of the data.
Using LineDataRecordWriter requires that the following record format attributes be set:
In conjunction with the Record or the RecordFormat classes, the LineDataRecordWriter takes a record as input to the writeRecord() method. (Record takes a RecordFormat as input when you instantiate it.)
The LineDataRecordWriter class provides methods that allow you to:
The following example shows one way to use the LineDataRecordWriter class to write a record:
// Example using the LineDataRecordWriter class. try { // create a ccsid ccsid_ = system_.getCcsid(); // create output queue and specify spooled file data to be *LINE OutputQueue outQ = new OutputQueue(system_, "/QSYS.LIB/RLPLIB.LIB/LDRW.OUTQ"); PrintParameterList parms = new PrintParameterList(); parms.setParameter(PrintObject.ATTR_PRTDEVTYPE, "*LINE"); // initialize the record format for writing data RecordFormat recfmt = initializeRecordFormat(); // create a record and assign data to be printed... Record record = new Record(recfmt); createRecord(record); SpooledFileOutputStream os = null; try { // create the output spooled file to hold the record data os = new SpooledFileOutputStream(system_, parms, null, outQ); } catch (Exception e) { System.out.println("Error occurred creating spooled file"); e.printStackTrace(); } // create the line data record writer LineDataRecordWriter ldw; ldw = new LineDataRecordWriter(os, ccsid_, system_); // write the record of data ldw.writeRecord(record); // close the outputstream os.close(); } catch(Exception e) { failed(e, "Exception occurred."); }