Hi
I have problem with read FBA data set when i use a ZFile zFile = new ZFile(filename, "rt"); I read a data set line by line but without "printer markers", when I use a ZFile zFile = new ZFile(filename, "rb"); whole data set is treated like i one line (but i see the "printer marekrs"), how I can read data set line by line with "printer markers"?
ZFILE
Re: ZFILE
Open mode = "rt" reads the data set in text streaming mode, the format of which is supplied by the IBM C-library via fopen(), fread(). You can verify in the C/C++ Programmer's Guide, but I suppose that this is the way that it is designed to work.
Open mode="rb" reads the data set in binary streaming mode (the records, one after another without separators). Again, working as designed.
The third option with IBM z/OS C library is to use binary record mode processing: "rb,type=record".
This will result in each read() returning an individual record. If you do this, you will see the ANSI CC in the first byte of each record.
Open mode="rb" reads the data set in binary streaming mode (the records, one after another without separators). Again, working as designed.
The third option with IBM z/OS C library is to use binary record mode processing: "rb,type=record".
This will result in each read() returning an individual record. If you do this, you will see the ANSI CC in the first byte of each record.
Re: ZFILE
I solved the problem this way:
Code: Select all
ZFile zFile = new ZFile(filename, "rb,type=record,noseek");
StringBuilder inStringBuilder = new StringBuilder();
byte[] recBuf = new byte[zFile.getLrecl()];
int nRead;
while((nRead = zFile.read(recBuf)) >= 0) {
inStringBuilder.append(new String(recBuf));
inStringBuilder.append("\r\n");
};
InputStream is = new ByteArrayInputStream(inStringBuilder.toString().getBytes());
return new InputStreamReader(is, "Cp1250");