Because you need to monitor whether a javacore file is generated in a directory on the server and do not want to run the proxy program on the server, you also think of a "bad idea": regular use of the FTP service, view the files in this directory.
At first, the sun.net. FTP. ftpclient package was used. It is embedded in JDK and easy to use, but it is so simple that it is not powerful. For example, you can only list objects and do not provide file-related information.
Later I found an org.apache.commons.net. FTP. FTP package that lists many attributes of a file, such as the size and owner. So I started the trial without saying anything. At that time, I killed the original Sun class and directly used apache class, but found that it was useless. I always got null when I called listfiles, neither of them can be copied online. I cannot solve this problem on the Internet. It is also complicated. In the end, you can only roll back. Fortunately, eclipse has the history function, saving a lot of time.
I saw the introduction of the Apache FTP package last night, and it seems to be very functional. So I studied it again this morning, I accidentally found that a guy built his own class on the Internet had a practice of outputting commands used in the process to the console. I thought of this to help find the cause. The problem is found: after connecting to the server, the server sends the syst command to the server, and the server returns an error:
Syst
215 UNIX type: l8 version: BSD-44
Port, 0
501 IP address for data destination doesn't match client's.
The method of connecting to the server is considered as a problem, so the enterlocalpassivemode method is called once after the connection.
Finally passed.
Add the original post address: Use the org.apache.commons.net. FTP package to develop the FTP client to implement progress reporting and resumable data transfer.