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.