资源简介
ftps 通过bat命令上传,里面sorcefile是具体的源代码,服务器端FileZilla Server(FTP服务器) v0.9.33 绿色汉化版 用这个我也上传过
代码片段和文件信息
import it.sauronsoftware.ftp4j.FTPClient;
import it.sauronsoftware.ftp4j.FTPDataTransferException;
import it.sauronsoftware.ftp4j.FTPException;
import it.sauronsoftware.ftp4j.FTPIllegalReplyException;
import it.sauronsoftware.ftp4j.FTPListParseException;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.NoSuchAlgorithmException;
import java.util.Properties;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.X509TrustManager;
public class ss {
/**
* @param args mjgch@163.com
* @throws FTPException
* @throws FTPIllegalReplyException
* @throws IOException
* @throws IllegalStateException
* @throws FTPListParseException
*/
public static void main(String[] args) throws IllegalStateException IOException FTPIllegalReplyException FTPException FTPListParseException {
X509TrustManager[] trustAll = new X509TrustManager[] { new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(
java.security.cert.X509Certificate[] certs String authType) {
}
public void checkServerTrusted(
java.security.cert.X509Certificate[] certs String authType) {
}
}
};
SSLContext sslContext = null;
FTPClient client = new FTPClient();
try {
sslContext = SSLContext.getInstance(“SSL“);
sslContext.init(null trustAll new java.security.SecureRandom());
SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
client.setSSLSocketFactory(sslSocketFactory);
client.setSecurity(FTPClient.SECURITY_FTPS);
} catch (KeyManagementException e) {
e.printStackTrace();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
try {
File pf = new File(“ftps.properties“);
InputStream pi = new FileInputStream(pf);
Properties p = new Properties();
p.load(pi);
//服务器IP地址
String ip=p.getProperty(“serverIp“);
//服务器端口
String port=p.getProperty(“serverPort“);
//服务器用户名
String userName=p.getProperty(“userName“);
//服务器密码
String passWord=p.getProperty(“passWord“);
//本地文件
String localFile=p.getProperty(“localFile“);
System.out.println(“----开始连接接服务器------“);
System.out.println(“IP> “+ip+“ 端口> “+port+“ 用户> “+userName);
client.connect(ip Integer.valueOf(port));
client.login(userName passWord);
String [] str=localFile.split(““);
System.out.println(“ 总共 “+str.length+“文件要上传“);
for(int i=0;i
System.out.println(“ “);
System.out.println(“ 第“+i+“文件“);
System.out.println(“---开始上传 “+str[i]+“ ---“);
client.upload(new java.io.File(str[i]));
System.out.println(“---上传结束---“);
System.out.println(“ “);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8176 2005-08-26 16:55 ftps命令上传\dnsns.jar
文件 66271 2010-09-17 17:00 ftps命令上传\ftp4j-1.5.1.jar
文件 36 2010-09-20 10:29 ftps命令上传\ftps.bat
文件 201 2010-09-20 11:33 ftps命令上传\ftps.properties
文件 802502 2005-08-26 18:33 ftps命令上传\localedata.jar
文件 839 2010-09-20 11:29 ftps命令上传\ss$1.class
文件 3791 2010-09-20 11:29 ftps命令上传\ss.class
文件 153235 2005-08-26 15:46 ftps命令上传\sunjce_provider.jar
文件 175811 2005-08-26 15:46 ftps命令上传\sunpkcs11.jar
文件 708 2010-09-20 10:48 ftps命令上传\test.class
文件 2204672 2010-09-20 11:39 ftps命令上传\使用说明.doc
文件 3202 2010-09-20 11:29 ftps命令上传\source\ss.java
目录 0 2010-09-20 11:44 ftps命令上传\source
目录 0 2010-09-20 11:33 ftps命令上传
----------- --------- ---------- ----- ----
3419444 14
评论
共有 条评论