Setting FTP active/passive mode with Java URLConnection

前端 未结 2 1262
梦如初夏
梦如初夏 2020-12-21 05:16

Is it possible to set FTP passive or active mode when working with URLConnection class? I cannot find any documentation on this, yet this is such a basic functionality that

2条回答
  •  旧巷少年郎
    2020-12-21 06:00

    To get FTP full fledged to work, you'll really need to fall back to low-level programming with Sockets. The URLConnection and consorts simply doesn't suit your needs (no support to enter into passive mode). Fortunately Apache Commons has already done a lot of work for you in flavor of Apache Commons Net FTPClient. To achieve what you need, just use FTPClient#enterLocalPassiveMode() or FTPClient#enterLocalActiveMode()

提交回复
热议问题