You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You do not need to read the whole dataset to get it's length. The example in the second link above does that, but if all you want is the length of the dataset you can just use getLrecl. What the second example does is it creates a RecordReader and uses getLrecl to get the size of the dataset, then it allocates a byte[] using the size and reads the entire dataset into the byte[].
This is not what you need. You can just directly create a ZFile and use the API in my first link.
Activity
fjeremic commentedon Mar 9, 2021
To get a dataset size you can use the
getLreclAPI from thecom.ibm.jzospackage. You can find full documentation here:https://www.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.zsecurity.api.70.doc/com.ibm.jzos/com/ibm/jzos/ZFile.html#getLrecl()
There is an example of using the API to read entire contents of a dataset into a
byte[]here:https://www.ibm.com/support/knowledgecenter/en/SSYKE2_7.1.0/com.ibm.java.zsecurity.api.71.doc/com.ibm.jzos/com/ibm/jzos/RecordReader.html
matmass commentedon Mar 10, 2021
Thanks for the reply.
So if I understand, we need to read the file and to count the bytes.
It means that we can't get directly the file size as a property.
Is-there any other way to get it?
Regards,
Mathias.
fjeremic commentedon Mar 10, 2021
You do not need to read the whole dataset to get it's length. The example in the second link above does that, but if all you want is the length of the dataset you can just use
getLrecl. What the second example does is it creates aRecordReaderand usesgetLreclto get the size of the dataset, then it allocates abyte[]using the size and reads the entire dataset into thebyte[].This is not what you need. You can just directly create a
ZFileand use the API in my first link.Here is how the constructor of
ZFilelooks (with examples):https://www.ibm.com/support/knowledgecenter/SSYKE2_7.0.0/com.ibm.java.zsecurity.api.70.doc/com.ibm.jzos/com/ibm/jzos/ZFile.html#ZFile(java.lang.String,%20java.lang.String)
So if your dataset is
SYS1.HELP(ACCOUNT)as in the example, you can do: