I am having some trouble with the ZFile.exists() method. I am using JZOS 1.2.2 and Java 1.4.2 on a z/OS 1.4 system.
When I call ZFile.exists() on a sequential dataset or a PDS, it works as it should (true if it exists, false if it doesn't). However, when I call it on a PDS member, it always returns false, whether it exists or not.
There are no errors in the system log. Turning on ZUtil.setLoggingLevel(ZUtil.LOG_TRACE) didn't produce anything that caught my eye. If I open a BufferedReader (using FileFactory.newBufferedReader()) on an existing member, it can read it with no problems.
Am I misunderstanding how exists() is used? Is it not supposed to be used for PDS members?
One another note: there is no documentation in the JZOS javadocs for ZFile.exists() or ZFile.dsExists(). It took me a while to realize that dsExists() does not expect // in front of the dataset names (and will always return false if they are there), unlike exists(). This might be worth noting in the documentation for a future JZOS release.
Issue with ZFile.exists()
Yes, ZFile.exists() doesn't work with PDS members in the current versions (1.2.2 or 1.2.3).
This has been fixed in an upcoming release, and the Javadoc has been corrected.
In the mean time, I can think of a couple of workarounds -
- I think that JRIO provides an api for this.
Here's an example from the JRIO User's guide:
IRecordFile rf = new RecordFile("//JOE.PDS.FILE(MEMBER)");
System.out.println("rf="+rf.getAbsolutePath()+
" exists="+
rf.exists());
- You could open a ZFile for input on the member and see if you get an exception.
This has been fixed in an upcoming release, and the Javadoc has been corrected.
In the mean time, I can think of a couple of workarounds -
- I think that JRIO provides an api for this.
Here's an example from the JRIO User's guide:
IRecordFile rf = new RecordFile("//JOE.PDS.FILE(MEMBER)");
System.out.println("rf="+rf.getAbsolutePath()+
" exists="+
rf.exists());
- You could open a ZFile for input on the member and see if you get an exception.