import org.apache.commons.net.ftp.FTPClient;
public class FTPExample {
public static void main(String[] args) {
String server = "ftp.example.com";
int port = 21;
String username = "your-username";
String password = "your-password";
try {
FTPClient ftpClient = new FTPClient();
ftpClient.connect(server, port);
ftpClient.login(username, password);
String remoteFilePath = "/path/to/remote/file.txt";
String localFilePath = "/path/to/local/file.txt";
ftpClient.retrieveFile(remoteFilePath, new FileOutputStream(localFilePath));
String localFile = "/path/to/local/file.txt";
String remoteFile = "/path/to/remote/file.txt";
ftpClient.storeFile(remoteFile, new FileInputStream(localFile));
ftpClient.logout();
ftpClient.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}