I am trying to read members from a fixed length pds and ZFile seems to return extra data which is not in the file.
for example,
this pds is defined with lrecl=80,blksize=18400,recfm=fb
this member ZRECSTST contains 2 records:
ISPF EDIT DISPLAY:
RECORD11111111111111111111111111111111111111111111111111111111111
RECORD 222222222222222222
i read the member with ZFile using the following code:
byte[] recBuf = new byte[zFile.getLrecl()];
while ((nRead = zFile.read(recBuf)) >= 0) {
count++;
sbuf = new String(recBuf);
System.out.println("record #"+count +"= " +sbuf);
the display shows the records read as being:
record #1= RECORD 11111111111111111111111111111111111111111111111111111111111111
RECORD
record #2= 222222222222222222
11111111111111111111111111111111111111111111111111111
RECORD
the word RECORD gets appended to the 1st record and extra spaces + word RECORD + data from 1st record
gets added onto the 2nd record.
these show up when i try to copy the data to a new file.
how can i avoid this and just get the data that ISPF edit shows it to be in the member?
________
SUNDANCE
ZFile.read() to prds members returning extraneous data
ZFile.read() to prds members returning extraneous data
Last edited by cscs010 on Sat Feb 12, 2011 2:23 pm, edited 1 time in total.
How did you open the ZFile?
ZFile is simply a wrapper on the z/OS C/C++ library's I/O functions.
The underlying C-library really has three modes for reading a dataset sequentially:
- "text"/stream e.g: new ZFile(name, "rt")
- "binary"/stream eg: new ZFile(name, "rb")
- "binary"/record eg: new ZFile(name, "rb,type=record,noseek")
Refer to the z/OS C/C++ Programmer's Guide for more info.
I'm assuming that you want "binary/record", but that you are maybe getting text/stream, in which case the C-library will trim spaces from each record and add newline characters. In stream mode, you will get the number of bytes that you ask to read, regardless of record boundaries.
In binary/record mode, each read will read a logical record.
For another example of doing record I/O with ZFile, see the ZFileCopy example program.
ZFile is simply a wrapper on the z/OS C/C++ library's I/O functions.
The underlying C-library really has three modes for reading a dataset sequentially:
- "text"/stream e.g: new ZFile(name, "rt")
- "binary"/stream eg: new ZFile(name, "rb")
- "binary"/record eg: new ZFile(name, "rb,type=record,noseek")
Refer to the z/OS C/C++ Programmer's Guide for more info.
I'm assuming that you want "binary/record", but that you are maybe getting text/stream, in which case the C-library will trim spaces from each record and add newline characters. In stream mode, you will get the number of bytes that you ask to read, regardless of record boundaries.
In binary/record mode, each read will read a logical record.
For another example of doing record I/O with ZFile, see the ZFileCopy example program.
i changed the input and ouput members to open in rb/wb mode.
the first record is okay but the 2nd gets part of the first record appended to it.
zFile = new ZFile("//DD:" + ddname + "(" + memberName + ")","rb,type=record,noseek");
tFile = new ZFile("//DD:" + ddname + "(" + newmemb + ")","wb");
this is the output file - (the display also shows the extra data being read in).
RECORD 11111111111111111111111111111111111111111111111111111111111111111
RECORD 222222222222222222
11111111111111111111111111111111111111111111111111111
RECORD
________
Hotels In Mexico
the first record is okay but the 2nd gets part of the first record appended to it.
zFile = new ZFile("//DD:" + ddname + "(" + memberName + ")","rb,type=record,noseek");
tFile = new ZFile("//DD:" + ddname + "(" + newmemb + ")","wb");
this is the output file - (the display also shows the extra data being read in).
RECORD 11111111111111111111111111111111111111111111111111111111111111111
RECORD 222222222222222222
11111111111111111111111111111111111111111111111111111
RECORD
________
Hotels In Mexico
Last edited by cscs010 on Sun Mar 06, 2011 7:39 am, edited 1 time in total.
filemode rb did work properly.
ignore my last update - the java class file had not been updated as i thought.
thanks for the info about using the binary mode file options.
________
Chevrolet cobalt ss specifications
ignore my last update - the java class file had not been updated as i thought.
thanks for the info about using the binary mode file options.
________
Chevrolet cobalt ss specifications