I am trying to transfer from the local file system to mainframe via the FTP protocol.I am using the apache.common.net library.The code is as follows,
FTPClient ftp = null;
InputStream in = null;
ftp = new FTPClient();
ftp.connect(hostName);
ftp.login(username, password);
ftp.enterLocalPassiveMode();
ftp.setFileType(FTP.ASCII_FILE_TYPE);
int reply = ftp.getReplyCode();
System.out.println("Received Reply from FTP Connection:" + reply);
if (FTPReply.isPositiveCompletion(reply))
System.out.println("Connected To Server Successfully");
else
System.out.println("Not connected to Server..Check ID,Password,connecivity");
boolean success = ftp.changeWorkingDirectory("'CICS.MAPLIB'");
if (success)
System.out.println("Successfully changed working directory.");
else
System.out.println("Failed to change working directory. See server's reply.");
File f1 = new File(location);
in = new FileInputStream(f1);
boolean done = ftp.storeFile("File", in);
in.close();
if (done)
System.out.println("FILE IS UPLOADED SUCCESSFULY");
else
System.out.println("FILE IS NOT UPLOADED SUCCESSFULLY");
ftp.logout();
ftp.disconnect();
I am taking username,password,hostname and location as parameters to the method.I previously created a PDS named 'USERID.CICS.MAPLIB' in z/OS.Now, the problem I am facing is that the file is not uploaded but however if I am not changing the working directory to 'USERID.CICS.MAPLIB', the file gets uploaded to the location 'USERID.File'.I am seeking to upload the file to a new member in the PDS I created earlier.If anyone has any solution, please help.
Thanks in Advance