Checks whether the path on the Mainframe FTP server is a file or folder.

I have Java code that transfers a file from FTP to Mainframe to my local system. The problem is how to determine if a given path is a file or folder? I canโ€™t use validation for extensions, since I donโ€™t know what extensions might be. Also the following code always returns false,

fileSystem.isFile("fileName"); 

Being a mainframe file system, the path is split into . instead of / , and therefore checking for . at the end also does not work.

Again I am transferring data from the input path to the output location using

 url="connection url of the mainframe" bufferedInputStream = new BufferedInputStream(url.getInputStream()); 

When I have files on the source path, it writes the contents of the file to the destination, and when the source path has a directory, it writes the names and other properties of the files in the directory to the destination.

An example output when the source is a directory is

 Name VV.MM Created Changed Size Init Mod Id QQQQ 01.00 2009/12/18 2009/12/18 12:15 18 18 0 XXXX RRRR 01.00 2009/12/18 2009/12/18 12:16 19 19 0 XXXXX 

How to determine if the source path is a file or folder?

+4
source share
3 answers

I found a way to determine if the path on the mainframe is a file or PDS (similar to a directory). I used the org.apache.hadoop.fs.ftp.FTPFileSystem library and the following snippet will work by returning a list of files.

 FTPFile[] files = ftp.listFiles(); 

Penetrating through files and checking file1.isFile() would be enough. Again, remember to go to the current working directory before listing files using ftp.cwd(inputPath);

For an explanation of the Mainframe file system, see Bruce Martin's answer and the following comments ..

+1
source

I have no answer, but it looks like you are playing Zos. For those who do not know anything about Zos

  • Zos do not have directories
  • What it calls in the directory is probably PDS (see PDS in Dataset ). For those who are not from the mainframe, think of it as a type of archive (i.e. Jar, Tar, zip, etc.). This is not an exact description, PDS has some limitations and uses jar files, but the jar file is the closest analogy on a PC, * the NIX world I can think of.

  • How do you detect them - not sure if there may be a file attribute that you can access

+2
source

You do not say which version of java you are using or using a special library for the host file system.

Can you use java.io.File # isDirectory () instead?

0
source

All Articles