import org.apache.commons.net.ftp.FTPSClient; import java.io.FileInputStream; import java.io.FileOutputStream; public class FTPSClientExample { public static void main(String[] args) { String server = "ftp.example.com"; int port = 21; String username = "username"; String password = "password"; try { FTPSClient ftpsClient = new FTPSClient(); ftpsClient.connect(server, port); ftpsClient.login(username, password); FileInputStream fileInputStream = new FileInputStream("localfile.txt"); ftpsClient.storeFile("remotefile.txt", fileInputStream); fileInputStream.close(); FileOutputStream fileOutputStream = new FileOutputStream("localfile.txt"); ftpsClient.retrieveFile("remotefile.txt", fileOutputStream); fileOutputStream.close(); ftpsClient.logout(); ftpsClient.disconnect(); } catch (Exception e) { e.printStackTrace(); } } } ftpsClient.setTrustManager(TrustManagerUtils.getAcceptAllTrustManager());


上一篇:
下一篇:
切换中文