Thanks for the help Stephen.
I tried using commons.net library.But I got exceptions.Please help me with this.The code I have written is below.
import org.apache.commons.net.ftp.*;
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;
public class MyFTP {
public static void main(String[] args) {
String user="user-name";
String psw="password";
String server="134.238.198.12";
String directory="/lic";
try {
FTPClient f= new FTPClient();
f.connect(server);
f.login(user, psw);
System.out.print(f.getReplyString());
/************* this does not work *************/
FTPFile[] files = f.listFiles();
for(int i=0;i< files.length;i++){
System.out.println("files:" + files[i].getName());
}//end of for loop
/************* up to this *************/
System.out.println();
f.disconnect();
}catch(Exception e){
System.out.println("Error:"+e);
}
}//end of function
}
}
These are the exception I got:
java.lang.NoClassDefFoundError: org/apache/oro/text/regex/MalformedPatternException
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createUnixFTPEntryParser(DefaultFTPFileEntryParserFactory.java:121)
at org.apache.commons.net.ftp.parser.DefaultFTPFileEntryParserFactory.createFileEntryParser(DefaultFTPFileEntryParserFactory.java:84)
at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:2306)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2055)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2106)
at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2146)
at MyFTP.main(MyFTP.java:23)
Exception in
thread "main"
Thank you.