ZFILE

General discussion on the JZOS batch launcher and toolkit
Post Reply
moral
Posts: 7
Joined: Thu Aug 08, 2013 2:24 am

ZFILE

Post by moral » Thu Aug 08, 2013 3:04 am

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"?

dovetail
Site Admin
Posts: 1850
Joined: Thu Jul 29, 2004 12:12 pm

Re: ZFILE

Post by dovetail » Thu Aug 08, 2013 4:02 pm

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.

moral
Posts: 7
Joined: Thu Aug 08, 2013 2:24 am

Re: ZFILE

Post by moral » Fri Aug 09, 2013 12:49 am

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");

Post Reply