java FTP上传发布文件源码示例

来源:互联网 发布:淘宝价格监控app 编辑:程序博客网 时间:2024/05/22 18:43

package ftp;

import com.enterprisedt.net.ftp.FTPClient;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPMessageCollector;
import com.enterprisedt.net.ftp.FTPTransferType;

public class ReaseWar {
 
     public static void main(String[] args) {
         String host = "172.25.165.152";
         String user = "mfguser";
         String password = "sfdcadmin";
         FTPClient ftp = null;
         try {
             ftp = new FTPClient(host);
             FTPMessageCollector listener = new FTPMessageCollector();
             ftp.setMessageListener(listener);
             ftp.login(user, password);
             ftp.setConnectMode(FTPConnectMode.PASV);
             ftp.setType(FTPTransferType.BINARY);
             String[] files = ftp.dir(".", true);
             String localPath = "D:/workspace/scion-spc-client/target/spcclient.war";
             String remoteFile = "spcclient.war";
             ftp.put(localPath, remoteFile);
             System.out.println("spcclient.war ftp finished.");
             localPath = "D:/workspace/scion-spc-server/target/spc.war";
             remoteFile = "spc.war";
             ftp.put(localPath, remoteFile);
             System.out.println("spc.war ftp finished.");
             ftp.quit();
 
         } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
 
 }

原创粉丝点击