ftp
来源:互联网 发布:北龙中网域名认证 编辑:程序博客网 时间:2024/06/06 21:41
public static String getFileFromFtp(String filePath,String localFloder,String modId){
Map map = commonConfJdbcDao.getFtpConfig(modId);
if(map == null || map.size() < 1){
return null;
}
String ip = map.get("ip") == null ? "" : map.get("ip").toString();
String account = map.get("account") == null ? "" : map.get("account").toString();
String password = map.get("password") == null ? "" : map.get("password").toString();
String path_root = map.get("path_root") == null ? "" : map.get("path_root").toString();
if( "".equals(ip) || "".equals(account) || "".equals(password)){
return null;
}
FtpUtil ftp = new FtpUtil(ip,account,password);
byte[] buffer = new byte[4096];
BufferedOutputStream output = null;
BufferedInputStream input = null;
InputStream is = null;
OutputStream os = null;
try{
if(!ftp.connectServer()){
return null;
}
if("".equals(filePath)){
return null;
}
is = ftp.download(path_root + "/" +filePath);
String localPath = localFloder + "/" + filePath;
os = new FileOutputStream(localPath);
input = new BufferedInputStream(is);
output = new BufferedOutputStream(os);
int n = (-1);
while ((n = input.read(buffer, 0, 4096)) > -1) {
output.write(buffer, 0, n);
}
output.flush();
return localPath;
} catch (Exception e){
e.printStackTrace();
return null;
}finally{
try{
if (input != null) input.close();
if(is != null) is.close();
if(output != null) output.close();
if(os != null) os.close();
}catch(Exception e){
e.printStackTrace();
}finally{
ftp.closeServer();
}
}
}
- FTP
- ftp
- ftp
- ftp
- ftp
- ftp
- FTP
- FTP
- ftp
- ftp
- ftp
- FTP
- FTP
- FTP
- FTP
- FTP
- ftp
- FTP
- vi/vim基本使用方法
- OpenSource security vulnerability aggregator (web scraper) and search engine
- DirectX 学习经典参考书籍 电子书下载
- static load Plugins
- ios 网络操作与AFNetworking
- ftp
- HTTP 状态消息
- 阿里云OTS(开放结构化数据服务)可视化管理工具的设计和功能介绍
- 数组指针和指针数组的区别
- php下memcache的应用(一)——什么是memcache
- HTTP 方法:GET 对比 POST
- activeMQ之点对点(PTP),监听器模式
- C++学习 STL之五:set/multiset用法详解
- HDU 1711 Number Sequence (数字KMP)