How to set working directory on FTPusing FTPClient

我是研究僧i 提交于 2020-01-03 05:35:09

问题


I'm using java FTPClient for FTPconnection. This library has storeFile method for saving a file on FTP. I use it like this:

FTPClient ftpClient = new FTPClient();
//code for connection and login
...
ftpClient.storeFile("test.jpg", stream); //stream is an InputStream

Now, I need to set working directory on FTP. For example I want to save my .jpg in the specific folder. Is ftpClient.storeFile("1/test.jpg", stream); correct? Or is there another solution?


回答1:


I think you should call FTPClient#changeWorkingDirectory() (the docs) prior to storeFile().



来源:https://stackoverflow.com/questions/27922851/how-to-set-working-directory-on-ftpusing-ftpclient

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!