jQuery in Action, 3rd edition
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 | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "Problem with my FTP client Program: MalformedPatternException" Watch "Problem with my FTP client Program: MalformedPatternException" New topic

Problem with my FTP client Program: MalformedPatternException

yathish Gatty
Ranch Hand

Joined: Oct 05, 2004
Posts: 31

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="";
String directory="/lic";
try {
FTPClient f= new FTPClient();
f.login(user, psw);

/************* 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 *************/


}catch(Exception 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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Problem with my FTP client Program: MalformedPatternException
It's not a secret anymore!