[英]Connect to FTP with Java
I would like to connect to a FTP from Java. 我想从Java连接到FTP。
I have done this: When the socket is connected to the FTP I get the 220 message from the socket´s inputstream (the welcome message from the FTP server). 我这样做了:当套接字连接到FTP时,我从套接字的输入流中收到了220条消息(来自FTP服务器的欢迎消息)。
Then I send this byte string through the sockets outputstream: "HELP". 然后,我通过套接字输出流“ HELP”发送此字节字符串。
But nothing is received from the server after sending that byte string. 但是,发送该字节字符串后,没有收到来自服务器的任何消息。 The inputstream is still listening but it is totaly quiet. 输入流仍在监听,但完全安静。
Have I missed something important? 我错过了重要的事情吗?
There's no need to reinvent the wheel. 没有必要重新发明轮子。 Instead, I would recommend using Apache's org.apache.commons.net.ftp.FTPClient
. 相反,我建议使用Apache的org.apache.commons.net.ftp.FTPClient
。 For more information, see Apache Commons Net . 有关更多信息,请参见Apache Commons Net 。
您需要在发送命令的末尾发送CR / LF线路终结器,例如
HELP\r\n
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.