首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 服务器 > Apache >

apache FTPS文件下传

2012-09-13 
apache FTPS文件上传boolean canConnection falseboolean isConnectionSuccess falseFTPSClient ftp

apache FTPS文件上传

boolean canConnection = false;boolean isConnectionSuccess = false;FTPSClient ftpsClient = null;try {ftpsClient = new FTPSClient("SSL");ftpsClient.setConnectTimeout(300000);//连接超时为5分钟ftpsClient.setDataTimeout(3600000);ftpsClient.connect(serverIP);//loger.info(traceStr+"Connected to " + serverIP + ".");int reply = ftpsClient.getReplyCode();canConnection = FTPReply.isPositiveCompletion(reply);  //可以判断是否可以连接//loger.info(""+"是否可以连接:"+canConnection);if(canConnection){isConnectionSuccess = ftpsClient.login(serverName, password);if(!isConnectionSuccess){System.out.println("服务器连接错误,请重新配置!");}else{System.out.println("连接服务器成功......");}}} catch (SocketException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();} catch (NoSuchAlgorithmException e) {e.printStackTrace();}
boolean isUpLoadSuccess = false;File file = new File(clientFilePath);System.out.println("上传文件之前大小:"+file.length()/1024.);FileInputStream input = null; try {input = new FileInputStream(clientFilePath);ftpsClient.enterLocalPassiveMode();isUpLoadSuccess = ftpsClient.storeFile(serverPath, input); } catch (FileNotFoundException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}finally{if(null!=input){try {input.close();} catch (IOException e) {e.printStackTrace();}}}
?
?

热点排行