风吹动你温柔发丝 2016-06-14 09:04 采纳率: 0%
浏览 4419

FTP获取文件列表出错,帮忙看看问题在哪里 ?

public static boolean downFile(String url,
int port,
String username,
String password,
String remotePath,
String fileName,
String localPath
)
{
boolean success = false;
FTPClient ftp = new FTPClient();
try
{
int reply;
ftp.connect(url, port);
ftp.login(username, password);
reply = ftp.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply))
{
ftp.disconnect();
return success;
}
ftp.changeWorkingDirectory(remotePath);

        for (FTPFile ff : fs)
        {
            if (ff.getName().equals(fileName))
            {
                File localFile = new File(localPath + "/" + ff.getName());
                OutputStream is = new FileOutputStream(localFile);
                ftp.retrieveFile(ff.getName(), is);
                is.close();
            }
        }

        ftp.logout();
        success = true;
    } catch (IOException e)
    {
        e.printStackTrace();
    } finally
    {
        if (ftp.isConnected())
        {
            try
            {
                ftp.disconnect();
            } catch (IOException ioe)
            {
            }
        }
    }
    return success;
}


FTPFile[] fs = ftp.listFiles();//到这里的时候总是报
        //org.eclipse.debug.core.DebugException:
        //com.sun.jdi.ClassNotLoadedException: 
        //Type has not been loaded occurred while retrieving component type of array.
  • 写回答

4条回答 默认 最新

  • threenewbee 2016-06-14 09:15
    关注

    导入 org.apache.commons.net.ftp 包,import 它。

    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器