import com.sap.gateway.ip.core.customdev.util.Message;
import java.util.HashMap;
import org.apache.commons.net.ftp.FTPClient
import org.apache.commons.net.ftp.FTPFile
def Message processData(Message message) {
//Body
def body = message.getBody(java.lang.String)as String;
FTPClient ftpClient = new FTPClient()
ftpClient.connect('host name');
ftpClient.login('user name','password');
//Get ftp body
ftpClient.enterLocalPassiveMode() ;
InputStream inputStream = ftpClient.retrieveFileStream(new String('ftp file name'.getBytes("UTF-8"), "iso-8859-1"));
ByteArrayOutputStream swapStream = new ByteArrayOutputStream();
byte[] buff = new byte[100];
int rc = 0;
int value =100;
while ((rc = inputStream.read(buff, 0, value)) > 0) {
swapStream.write(buff, 0, rc);
}
body = swapStream.toString();
def messageLog = messageLogFactory.getMessageLog(message);
messageLog.addAttachmentAsString("log ftp data", body.toString(), "text/plain");
return message;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
9 | |
7 | |
6 | |
4 | |
4 | |
3 | |
3 | |
3 | |
3 |