I have a problem with FTP. On mainframe is created data set with xml i send this xml via FTP witen in java. here is the code:
Code: Select all
ZFile zFilePEEout = new ZFile("//DD:PEEOUT", "rb,type=record,noseek");
SendFTP send = new SendFTP(address, user, pass, ftpEnc);
InputStream input = zFilePEEout.getInputStream();
send.uploadFile(input, name, dir);
zFilePEEout.close();
send.disconnect();
Code: Select all
public class SendFTP {
FTPClient ftp = null;
public SendFTP(String host, String user, String pwd, String encFTP) throws Exception{
ftp = new FTPClient();
ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
int reply;
ftp.connect(host);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftp.disconnect();
throw new Exception("Exception");
}
ftp.login(user, pwd);
ftp.enterLocalPassiveMode();
}
public void uploadFile(InputStream input, String fileName, String hostDir)
throws Exception {
this.ftp.storeFile(hostDir + fileName, input);
}
public void disconnect(){
if (this.ftp.isConnected()) {
try {
this.ftp.logout();
this.ftp.disconnect();
} catch (IOException f) {
System.out.println("Exception: "+f);
}
}
}
What code use to ftp this data set?