| Author |
Problem with my FTP client Program: MalformedPatternException
|
yathish Gatty
Ranch Hand
Joined: Oct 05, 2004
Posts: 31
|
|
HI I am writing an FTP application using org.apache.commons.net. I am able to connect and disconnect with my server. As a start up, I am trying to print the list of files in the specified directory.(As later on I want to check whether the file is directory or not) But it gave me bunch of exception although it compiled well. Here is my code: 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="10.16.56.216"; 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" I dont know how to proceed. All I need to do is download a file from a specified directory in binary mode. That is my goal. But before that I tried to see whether I am able to get the files/directory listing from a specified directory. Pls help/suggest me If I am doing anything wrong. Advance Thanks
|
 |
 |
|
|
subject: Problem with my FTP client Program: MalformedPatternException
|
|
|