Path switching of FTP upload changeworkingdirectory() method

During uploading, the ftpclient provides the upload method. For the second parameter path of upload (file, path), the path to which to upload,

FTP uses the changeworkingdirectory () method to replace the command CD in CMD,

In the process of uploading, the path may not exist, so you need to judge whether it exists. If it exists, it will not be created. If it does not exist, it will be created. The code is as follows

private static FTPClient ftp;

ftp. changeWorkingDirectory(path);// Switch to the path you sent

//The following code is to create a folder with the name of the current date under the path, such as 20171018

String curDate = new SimpleDateFormat("yyyyMMdd"). format(new Date()); ftp. makeDirectory(curDate);// Judge whether the 20171018 folder exists or not, and then execute this line of code FTP changeWorkingDirectory(curDate);// Switch to 20171018 folder under path

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>