Use the Apachecommons-net package to overwrite and delete files on the server.

Source: Internet
Author: User
To ensure security, you need to rewrite the file with a random number of 1 kb before deleting the file on the ftp server. This operation requires the FTPClient class under the Apachecommons-net package. In order to rewrite the file, I used the storeFileStream (Stringremote) method of this class. This method returns an OutputStream, not at first

After receiving a task: to ensure securityFtpYou must use a random number of 1 kb to overwrite a file on the server.

This operation requires the FTPClient class under the Apache commons-net package. to rewrite the file, I used storeFileS of this class.TrEam (String remote) method. This method returns an OutputStream. At first, the deleteFile method of the FTPClient class is called without notice of the flush and close Methods of OutputStream. If the method runs successfully, true is returned, however, the deleteFile method returns true and does not delete the file. A csdn User told me that a file was opened and not deleted successfully.

Later, I called the flush and close Methods of OutputStream. It is always correct to read and write the first file. When the second file is read and written by the same API, the block is blocked. My friend Haibo reminded me that the storeFileStream (String remote) method cannot process the stream immediately, so you need to manually call completePendingCommand. FTPClient requires that the completePendingCommand be executed after the stream operation to ensure that the stream processing is complete. Because the stream processing is not real-time, there is no way to manually call completePendingCommand. The public boolean storeFile (String remote, InputStream local) method is used to solve the problem.

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.