Please find the below code:
import org.apache.commons.net.ftp.FTPClient;
import java.io.IOException;
import java.io.FileOutputStream;
import java.net.SocketException;
public class ftpTest {
public static void main(
String[] args) throws SocketException, IOException {
FTPClient client = new FTPClient();
FileOutputStream fos = null;
fos = new FileOutputStream("D:/myfile.pdf");
String hostfilename = "/home/injm1/XLMP";
client.connect("nmfinccmdev", 22);
client.login("xxx", "xxx");
client.retrieveFile(hostfilename, fos);
fos.close();
client.disconnect();
}
}
But soon after connect i get an following exception
Exception in
thread "main" org.apache.commons.net.MalformedServerReplyException: Could not parse response code.
Server Reply: SSH-1.99-OpenSSH_5.0
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:270)
at org.apache.commons.net.ftp.FTP._connectAction_(FTP.java:321)
at org.apache.commons.net.ftp.FTPClient._connectAction_(FTPClient.java:522)
at org.apache.commons.net.SocketClient.connect(SocketClient.java:162)
at ftpTest.main(ftpTest.java:12)