aspose file tools
The moose likes Sockets and Internet Protocols and the fly likes Problem with my FTP client Program: MalformedPatternException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "Problem with my FTP client Program: MalformedPatternException" Watch "Problem with my FTP client Program: MalformedPatternException" New topic
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
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Problem with my FTP client Program: MalformedPatternException
 
Similar Threads
Problems with Jakarta FTPFile class
FTPS / FTP over SSL with Jakarta Commons Net
Specified file not found
Connect to FTP site with Apache commons net FTP client through Proxy
How to Check whether the file in the Ftpserver is a directory or not?