Apache Commons NET: Should I create a new FTPClient object on each connection or reuse one?

前端 未结 3 657
遇见更好的自我
遇见更好的自我 2021-01-12 05:08

I\'m just wondering: in my Java application, each time I need to connect to an FTP server, should I create a new FTPClient object, or should I create one FTPClient() object

3条回答
  •  情话喂你
    2021-01-12 05:41

    Reusing would be better since you wont need a new instance every time you are creating a new connection, even to a new server. Because the connect and disconnect methods can do the job for you.

    So reuse as many objects as you can.

提交回复
热议问题