Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
12.9k views
in Java FTP by (160 points)
Hello,

I tried to connect on the proFTPD 1.2.8 server and when I execute my java
application I've the following error message :

java.text.ParseException: Unparseable date: "drwxr-xr-x 3"
at java.text.DateFormat.parse(DateFormat.java:335)
at com.enterprisedt.net.ftp.WindowsFileParser.parse(WindowsFileParser.java:107)
at com.enterprisedt.net.ftp.FTPFileFactory.parse(FTPFileFactory.java:196)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:1816)
at test.TestEdtFtp.main(TestEdtFtp.java:25)

Here is my java code :

package test;

import com.enterprisedt.net.ftp.*;

public class TestEdtFtp
{
public static void main(String[] args)
{

//
//here is example code
//
String server = "192.168.0.1";
String user = "test";
String passwd = "test";
//
try
{
FTPClient ftpConnect = new FTPClient(server) ;
ftpConnect.login(user, passwd);
FTPFile[] files = ftpConnect.dirDetails("tmp") ;

for (int i = 0 ; i < files.length ; i++)
{
System.out.print(files[i].getName() + " -- ");
System.out.print(files[i].getType() + " -- ");
//System.out.print(files[i].lastModified().toString() + " -- ");
System.out.print(files[i].size());
}

ftpConnect.quit();

}
catch (Exception e)
{
e.printStackTrace();
}
}
}

The server run with the mandrake linux distribution. The tmp directory exist in the user test root directory.

Someone have an idea ?

Thanks,

13 Answers

0 votes
by (161k points)
For some reason the WindowsFileParser is being used. You can set the UnixFileParser manually to force its use, or post the debug for inspection.

If you login in to the FTP server via the command line and type 'quote syst' what do you get? If you get back '215 UNIX Type: L8' then the UnixFileParser should be being used ...
0 votes
by
Thanks, I do that and now we have an other exception :

java.text.ParseException: Unparseable date: "Jan-14-2005-22:40"
at java.text.DateFormat.parse(DateFormat.java:335)
at com.enterprisedt.net.ftp.UnixFileParser.parse(UnixFileParser.java:223)
at com.enterprisedt.net.ftp.FTPFileFactory.parse(FTPFileFactory.java:185)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:1816)
at test.TestEdtFtp.main(TestEdtFtp.java:27)

May be the problem come with the french format date !!

I'll see the api documentation to fix it.
0 votes
by (160 points)
OK, I fixed my problem. I found in the edtftpj source code that I needed to call
the setParserLocale method with de FTPClient object.

Thanks for your help.
0 votes
by
please, how can i set the UnixFileParser manually to force its use?
thanks
0 votes
by (161k points)
search the forums, I think there is a post on it

please, how can i set the UnixFileParser manually to force its use?
thanks
0 votes
by (180 points)
Hi I have the same problem than Alto but I don
0 votes
by (180 points)
The error is:

java.text.ParseException: Unparseable date: "Aug-18-2006-12:41"

and my code:

            ftpClient2 = new FTPClient();
            ftpClient2.setProgressMonitor(new MyFTPProgressMonitor());
            UnixFileParser unixFileParser = new UnixFileParser();
            unixFileParser.setLocale(Locale.ENGLISH);
            ftpClient2.setFTPFileFactory(new FTPFileFactory(unixFileParser));
            ftpClient2.setRemoteHost("ftp.qq.es");
            ftpClient2.connect();
            ftpClient2.login("kk", "devaca");

            ftpClient2.setConnectMode(FTPConnectMode.ACTIVE);
            ftpClient2.chdir("/");
            FTPFile[] files = ftpClient2.dirDetails("/");
            System.err.println("**** files.length: " + files.length);
            for(int i=0; i<files.length; i++){
                System.err.println("****** " + files[i].getName());
            }

0 votes
by
hello

it's easier to use setParserLocale method on FTPClient.

peace
0 votes
by (180 points)
Hi,
I am running edtFTPj v. 1.5.2 on a Windows XP machine and connect to a WFTPD FTP server installed on a Windows 2000 Professional.
I got the same problem as alto had already reported. Somehow the WindowsFileParser instead of the UnixFileParser is being used.
Below the java exception I get:

02/05/2006 18:06:07:140 ERROR [Thread-2436] [SystemException.<init>] [1146585967140.15] java.text.ParseException: Unparseable date: "drwxrwxrwx 1"
at java.text.DateFormat.parse(DateFormat.java:335)
at com.enterprisedt.net.ftp.WindowsFileParser.parse(WindowsFileParser.java:111)
at com.enterprisedt.net.ftp.FTPFileFactory.parse(FTPFileFactory.java:246)
at com.enterprisedt.net.ftp.FTPClient.dirDetails(FTPClient.java:2002)
at com.tilab.common.ftp.FtpManager.listDetails(Unknown Source)
...

Here the output I get from a command line FTP client:

ftp> dir lok
200 PORT command okay
150 File Listing Follows in ASCII mode
drwxrwxrwx 1 noone nogroup 0 May 2 11:22 .
drwxrwxrwx 1 noone nogroup 0 May 2 11:22 ..
-rwxrwxrwx 1 noone nogroup 553672 Apr 18 12:07 squatter-OADM-1 trottolo.dat
-rwxrwxrwx 1 noone nogroup 553672 Mar 30 15:13 squatter-OADM-1jghj.dat
-rwxrwxrwx 1 noone nogroup 553672 May 2 11:22 squatterk-OADM-1 pingo.dat
-rwxrwxrwx 1 noone nogroup 553672 Apr 20 17:16 squatterk-OADM-1 troll.dat
226 Transfer finished successfully.
ftp: 442 bytes received in 0,00Seconds 442000,00Kbytes/sec.
ftp>

The very strange thing is the following: if the directory for which I am calling dirDetails() is dated 30.04.06 or before, the command succeeds and I get the correct output. If however the directory is dated 01.05.06 or later it fails with the exception above.

I read about the possibility to force set the UnixFileParser, but I need the FTP client working no matter which FTP server is, it should work also with Windows notation!

Here the output of 'quote syst' command:
ftp> quote syst
215 MSDOS A N (WFTPD by Texas Imperial Software)
ftp>

Can you please tell me what other information do you need to investigate on?
Thanks,
Alberto
0 votes
by (51.2k points)
Hi

The guy who's best qualified to respond to your query is away until Wednesday. I've sent him an e-mail to ask him to respond to your message and I expect he will do so soon after he comes back.

- Hans (EDT)

Categories

...