import com.enterprisedt.net.ftp.*; import com.enterprisedt.net.ftp.ssh.*; FTPClient ftp = new FTPClient(); FTPSSHClient sftp = new FTPSSHClient(); ftp.setRemoteHost("ftp.example.com"); ftp.setRemotePort(21); ftp.setUserName("username"); ftp.setPassword("password"); sftp.setRemoteHost("sftp.example.com"); sftp.setRemotePort(22); sftp.setUserName("username"); sftp.setAuthentication(FTPSSHClient.AUTH_PUBLICKEY, "privateKeyPath"); File localFile = new File("localfile.txt"); ftp.upload(localFile, "/remotefolder/remoteFile.txt"); File localFile = new File("localfile.txt"); ftp.download("/remotefolder/remoteFile.txt", localFile); ftp.disconnect();


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