Common-net 的相关问题

我在使用common-net 的时候,ftp地址使用正确,而我密码故意之后,提示登录成功,但显示文件夹下的目录长度是,显示为0,请问这是什么情况,应该如何处理呢?
[code="java"]
ftpClient.setDefaultPort(21);
ftpClient.connect(ftpServerAddress);
ftpClient.login(ftpServerAccount, ftpServerPassword);
FTPFile[] remoteFiles = ftpClient.listFiles(ftpServerRemoteDir);
String[] names = ftpClient.listNames();
[/code]
[b]问题补充:[/b]
我在使用common-net 的时候,ftp地址使用正确,而我密码故意写错之后,系统仍然提示登录成功,但显示文件夹下的目录长度是,显示为0,请问这是什么情况,应该如何处理呢?
[code="java"]
ftpClient.setDefaultPort(21);
ftpClient.connect(ftpServerAddress);
ftpClient.login(ftpServerAccount, ftpServerPassword);
FTPFile[] remoteFiles = ftpClient.listFiles(ftpServerRemoteDir);
String[] names = ftpClient.listNames();
[/code]

例子
[code="java"]
package com.commonsbook.chap10;
import org.apache.commons.net.ftp.*;

import java.io.*;
public class FTPClientTrial {
public static void main(String[] args) {
new FTPClientTrial().useFTP("ftp. example.com", "/directory", "file",
"username", "password");
}

public void useFTP(String ftpserver, String directoryName,
    String filetoUpload, String username, String password) {
    FTPClient ftpClient = new FTPClient();

    try {
        ftpClient.connect(ftpserver);
        System.out.print(ftpClient.getReplyString());

        // check reply code.
        if (!FTPReply.isPositiveCompletion(ftpClient.getReplyCode())) {
            ftpClient.disconnect();
            System.out.println("Connection refused.");
            return;
        }

        ftpClient.login(username, password);
        System.out.println("Workdir >>" +
            ftpClient.printWorkingDirectory());
        ftpClient.changeWorkingDirectory(directoryName);

        //Store file
        FileInputStream input = new FileInputStream(filetoUpload);
        ftpClient.storeFile(filetoUpload, input);

        //List all Files and directories
        FTPFile[] files = ftpClient.listFiles();

        if (files != null) {
            for (int i = 0; i < files.length; i++) {
                 //If file print name and size
                 if (files[i].isFile()) {
                     System.out.println("File >> " + files[i].getName() +
                         "\tSize >>" + files[i].getSize());
                 }
            }
        }
        ftpClient.logout();
        ftpClient.disconnect();
    } catch (IOException e) {
        if (ftpClient.isConnected()) {
            try {
                ftpClient.disconnect();
            } catch (IOException f) {
                // do nothing
            }
        }

        e.printStackTrace();
    }
}

}

[/code]

你写的代码有些问题

看看
http://www.iteye.com/topic/173786