wolfmanzyj 2015-02-07 02:28 采纳率: 0%
浏览 5887

FtpClient 中completePendingCommand 方法卡住

自己的代码如下:

    RandomAccessFile raf = new RandomAccessFile(localFile, "r");
    OutputStream out;

            //读写操作
            ..................

            out.flush();
    raf.close();
    out.close();

    Log.i(TAG, "befor setDefaultTimeout");
    CLogger.i(TAG, "befor setDefaultTimeout");

    ftpClient.setDefaultTimeout(1000 * 10);

    Log.i(TAG, "befor completePendingCommand");

    boolean result = ftpClient.completePendingCommand();

    Log.i(TAG, "after completePendingCommand");

从log中看出:
befor completePendingCommand 已打印
after completePendingCommand 未打印
可以判断是completePendingCommand方法一直没有返回。

我看了FtpClient 的源码,发现completePendingCommand做的事比较简单:
public boolean completePendingCommand() throws IOException
{
return FTPReply.isPositiveCompletion(getReply());
}
不知道为何会阻塞。
求高人指点,多谢!!

  • 写回答

2条回答

  • Lemon-Girl 2017-07-25 15:15
    关注

    查了一下,completePendingCommand()会一直在等FTP Server返回226 Transfer complete,但是FTP Server只有在接受到InputStream执行close方法时,才会返回。所以先要执行InputStream的close方法。

    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!