I have used this code
import org.apache.commons.net.ftp.FTPClient;
import java.io.FileInputStream;
import java.io.IOException;
public class FTPClientExample {
public static void main(String[] args) {
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect("hostname");
client.login("user", "pwd");
String filename = "D:\\Task\\try.txt";
fis = new FileInputStream(filename);
client.storeFile(filename, fis);
client.logout();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fis != null) {
fis.close();
}
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
when i run this,i get the message task complete.But i couldnt find out which folder i should look for the file.some one pls help me?
you are trying to upload on the path
D:\\Task\\try.txt.I guess that is your source file path.You should write something like
where ftpPath should be the FTP server location where you want to upload the file.
Edit:: File path structure