Hi guys

I'm trying to write a basic FTP component, as part of a bigger
application.

This is my first app, and I'm struggling a little (Perl developer not
OO either).

I have the following basic script

package com.test.ftp;

import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPFile;

import android.app.Activity;
import android.os.Bundle;

public class ftptest extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        FTPClient ftpClient = new FTPClient();
        try {
                ftpClient.connect("fto.drivehq.com", 21);
                ftpClient.login("myaccount", "password");

                System.out.println("Reply-> " +
ftpClient.getReplyString());

                FTPFile[] ftpFiles = ftpClient.listFiles();

                System.out.println("aaaaaa: " + ftpFiles.length);

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



        setContentView(R.layout.main);
    }
}

I've enabled the INTERNET permission on the MANIFEST and I connect OK.

I've also downloaded the apache commons net 2.0 and gone and added
commons-net-ftp-2.0.jar to build path.

I'm developing in eclipse.  When I get to the line 'FTPFile[] ftpFiles
= ftpClient.listFiles();' it seems to get stuck on there, then I get
the following.

07-19 21:29:50.110: WARN/System.err(945):
org.apache.commons.net.ftp.FTPConnectionClosedException: Connection
closed without indication.
07-19 21:29:50.110: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTP.__getReply(FTP.java:297)
07-19 21:29:50.120: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:490)
07-19 21:29:50.135: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:534)
07-19 21:29:50.135: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTP.port(FTP.java:862)
07-19 21:29:50.135: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:
463)
07-19 21:29:50.135: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:
2296)
07-19 21:29:50.139: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:
2269)
07-19 21:29:50.139: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2046)
07-19 21:29:50.139: WARN/System.err(945):     at
org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:2093)
07-19 21:29:50.150: WARN/System.err(945):     at
com.test.ftp.ftptest.onCreate(ftptest.java:21)
07-19 21:29:50.150: WARN/System.err(945):     at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
07-19 21:29:50.150: WARN/System.err(945):     at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:
2231)
07-19 21:29:50.150: WARN/System.err(945):     at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:
2284)
07-19 21:29:50.150: WARN/System.err(945):     at
android.app.ActivityThread.access$1800(ActivityThread.java:112)
07-19 21:29:50.150: WARN/System.err(945):     at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
07-19 21:29:50.150: WARN/System.err(945):     at
android.os.Handler.dispatchMessage(Handler.java:99)
07-19 21:29:50.150: WARN/System.err(945):     at
android.os.Looper.loop(Looper.java:123)
07-19 21:29:50.150: WARN/System.err(945):     at
android.app.ActivityThread.main(ActivityThread.java:3948)
07-19 21:29:50.161: WARN/System.err(945):     at
java.lang.reflect.Method.invokeNative(Native Method)
07-19 21:29:50.161: WARN/System.err(945):     at
java.lang.reflect.Method.invoke(Method.java:521)
07-19 21:29:50.161: WARN/System.err(945):     at
com.android.internal.os.ZygoteInit
$MethodAndArgsCaller.run(ZygoteInit.java:782)
07-19 21:29:50.180: WARN/System.err(945):     at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-19 21:29:50.180: WARN/System.err(945):     at
dalvik.system.NativeStart.main(Native Method)

It's driving me nuts, is there something  I'm missing, because I've
followed so many different tutorials but noone elses code seems to run
when it gets to the point of FTPFiles......

Thanks!

Chris

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to