I want to add my file to a specific directory,not root directory in my ftp server. what can I do? here is my java code:
FTPClient client = new FTPClient();
String filename = "out.txt";
// Read the file from resources folder.
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
InputStream is = classLoader.getResourceAsStream(filename);
try {
client.connect("18.14.18.17");
boolean login = client.login("root", "root");
if (login) {
System.out.println("Login success...");
// Store file to server
client.storeFile(filename, is);
client.logout();
}
this code adds the file to my root directory in my ftp server.
I can use method client.changeWorkingDirectory("server directory").
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.