FTP Upload mit Android

Integrating the required library from Apache with Eclipse: Instructions.


import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

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

import android.util.Log;

import de.egraveyard.android.view.ItemUploader;

public class FtpUpload {
    private static final String TAG = ItemUploader.class.getSimpleName();

    String serverAdress = "ftp.lala.de";
    String userName = "ftpUser";
    String password = "lala";
    String serverDirectory = "/android";
    //String localFilePath = "/data/anr/traces.txt";
    //String remoteFileName = "traces2.txt";

    public boolean uploadImage(String localFilePath, String remoteFileName) {
        boolean result = false;

        FTPClient ftpClient = new FTPClient();

        try {

            ftpClient.login(this.userName, this.password);
        } catch (IOException e) {
                    "IOException ftp Client could not be established.controll Login, Server, Pw.");
        Log.d(TAG, "FTP Server Response: " + ftpClient.getReplyString());

        BufferedInputStream buffIn = null;
        try {
            buffIn = new BufferedInputStream(new FileInputStream(localFilePath));
        } catch (FileNotFoundException e) {
                    "FileNotFoundException: local File to be uploaded not Found: " + localFilePath);

        try {
            result = ftpClient.storeFile(remoteFileName, buffIn);
        } catch (IOException e) {
            Log.d(TAG, "IOException: remote File could not be accessed");
        try {
        } catch (IOException e) {
            Log.d(TAG, "IOException: buffIn.close()");

        try {
        } catch (IOException e) {
            Log.d(TAG, "IOException: ftpClient close/logout");

        return result;
  1. Code super! Have tested this with me, but unfortunately does not.

    result = ftpClient.storeFile(remoteFileName, buffIn); here comes the error !

    Eclipse keeps jumping in here “catch” I get there and then

    Log.d(DAY, “IOException: remote File could not be accessed”); –> zero

    What am I doing wrong??? Help