<dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
properties
ftp.host=ftp.example.com
ftp.port=21
ftp.user=your-username
ftp.password=your-password
ftp.path=/path/to/remote/directory
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.WagonException;
import org.apache.maven.wagon.proxy.ProxyOptions;
import org.apache.maven.wagon.repository.Repository;
public class FtpUploadExample {
public static void main(String[] args) {
try {
Wagon wagon = newwagon();
ProxyOptions proxyOptions = new ProxyOptions();
proxyOptions.setProxyHost("proxy.example.com");
proxyOptions.setProxyPort(8080);
Repository repository = newRepository();
repository.setUrl("ftp://" + ftp.host + ":" + ftp.port + "/" + ftp.path);
repository.setProxyOptions(proxyOptions);
wagon.connect(repository);
wagon.upload("path/to/local/file", "/path/to/remote/file");
wagon.close();
} catch (WagonException e) {
e.printStackTrace();
}
}
}
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.WagonException;
import org.apache.maven.wagon.proxy.ProxyOptions;
import org.apache.maven.wagon.repository.Repository;
public class FtpDownloadExample {
public static void main(String[] args) {
try {
Wagon wagon = newwagon();
ProxyOptions proxyOptions = new ProxyOptions();
proxyOptions.setProxyHost("proxy.example.com");
proxyOptions.setProxyPort(8080);
Repository repository = newRepository();
repository.setUrl("ftp://" + ftp.host + ":" + ftp.port + "/" + ftp.path);
repository.setProxyOptions(proxyOptions);
wagon.connect(repository);
wagon.download("/path/to/remote/file", "path/to/local/file");
wagon.close();
} catch (WagonException e) {
e.printStackTrace();
}
}
}