1、
使用HttpURLConnection上传文件:
每个 HttpURLConnection 实例都可用于生成单个请求,但是其他实例可以透明地共享连接到 HTTP 服务器的基础网络。请求后在 HttpURLConnection 的 InputStream 或 OutputStream 上调用 close() 方法可以释放与此实例关联的网络资源
Quartz框架
ZipOutputStream的使用
线程池:
ftp4j的使用:
使用java的ftp连接工具, 连接失败, 最后发现是代理的原因, 使用了ftp4j, 但是, 使用ftp4j后, 报错, 说是socket连接超时。
FTPClient client = new FTPClient();
client.connect("10.2.22.1", 21);
// client.connect("127.0.0.1", 21);
client.login("htftp", "htftp");
SOCKS4Connector socks4 = new SOCKS4Connector("10.2.16.90", 808);
FTPFile[] list = client.list();
for (FTPFile file : list) {
System.out.println(file);
}
client.download("logo_cn.png", new java.io.File("d:/logo.jpg"));
client.connect("10.2.22.1", 21);
// client.connect("127.0.0.1", 21);
client.login("htftp", "htftp");
SOCKS4Connector socks4 = new SOCKS4Connector("10.2.16.90", 808);
FTPFile[] list = client.list();
for (FTPFile file : list) {
System.out.println(file);
}
client.download("logo_cn.png", new java.io.File("d:/logo.jpg"));
查到一下说明:
ftp4j 1.7
ftp4j is a Java library that implements a full-featured FTP client. With ftp4j embedded in your application, you can transfer files (upload and download), browse the remote FTP site (directory listing included), and create, delete, rename, and move remote directories and files.
Changes
A change has been made in the FTP connectors architecture. FTPConnector is no longer an interface: it is now an abstract class implementing timeout aware connections. Timeouts for connection, read, and close operations can be set by the caller. A connection attempt to a remote FTP server can now be aborted, calling the brand new abortCurrentConnectionAttempt() method in FTPClient. Moreover, a bug has been fixed in the HTTPTunnelConnector.
ftp4j is a Java library that implements a full-featured FTP client. With ftp4j embedded in your application, you can transfer files (upload and download), browse the remote FTP site (directory listing included), and create, delete, rename, and move remote directories and files.
Changes
A change has been made in the FTP connectors architecture. FTPConnector is no longer an interface: it is now an abstract class implementing timeout aware connections. Timeouts for connection, read, and close operations can be set by the caller. A connection attempt to a remote FTP server can now be aborted, calling the brand new abortCurrentConnectionAttempt() method in FTPClient. Moreover, a bug has been fixed in the HTTPTunnelConnector.
于是, 加上
client.abortCurrentConnectionAttempt();后成功解决!
说起代理, 让人郁闷, 还遇到一个问题: