Java-FTP Programming

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.