I have a Java code that transfers file from FTP on Mainframe to my local system . The problem is how do I tell if the given path is a file or folder ? I cannot use the check for extensions as i don’t know what the possible extensions can be . Also the following code always returns false ,
fileSystem.isFile("fileName");
Being a mainframe filesystem , the path is seperated by . instead of / and hence a check for . at the end also doesnt work.
Again I stream data from the input path to output location using
url="connection url of the mainframe"
bufferedInputStream = new BufferedInputStream(url.getInputStream());
When I have files at the source path , it writes the content of the file to the destination , and when the source path has a directory it writes the the names and other properties of the files at the directory to the destination.
Sample 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 do I determine if the source path is a file or folder ?
I found a way to determine if the path on mainframe is a file or PDS (analogically a directory ) . I used
org.apache.hadoop.fs.ftp.FTPFileSystemlibrary and the following snippet would work by returning the list of files .Looping through the
filesand checkingfile1.isFile()would suffice.Again remember to change to the current working directory before listing the files using
ftp.cwd(inputPath);For an explanation on Mainframe file system please refer to Bruce Martin’s answer and the comments that follow. .