|  |  |  | 
|---|
|  |  |  | import org.apache.http.impl.client.CloseableHttpClient; | 
|---|
|  |  |  | import org.apache.http.impl.client.HttpClientBuilder; | 
|---|
|  |  |  | import org.apache.http.util.EntityUtils; | 
|---|
|  |  |  | import org.apache.xpath.operations.Bool; | 
|---|
|  |  |  | import sun.misc.BASE64Encoder; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** */ | 
|---|
|  |  |  | 
|---|
|  |  |  | // 设置PassiveMode传输 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ftpClient.enterLocalPassiveMode(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | // 设置以二进制流的方式传输 | 
|---|
|  |  |  | ftpClient.setFileType(FTP.BINARY_FILE_TYPE); | 
|---|
|  |  |  | ftpClient.setControlEncoding("GBK"); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public boolean uploadInputstreamBatch(InputStream inputStream, String remote, Boolean close , Integer index )  { | 
|---|
|  |  |  | // 设置PassiveMode传输 | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | ftpClient.enterLocalPassiveMode(); | 
|---|
|  |  |  | // 设置以二进制流的方式传输 | 
|---|
|  |  |  | ftpClient.setFileType(FTP.BINARY_FILE_TYPE); | 
|---|
|  |  |  | ftpClient.setControlEncoding("GBK"); | 
|---|
|  |  |  | // 对远程目录的处理 | 
|---|
|  |  |  | String remoteFileName = remote; | 
|---|
|  |  |  | if (remote.contains("/")) { | 
|---|
|  |  |  | remoteFileName = remote.substring(remote.lastIndexOf("/") + 1); | 
|---|
|  |  |  | // 创建服务器远程目录结构,创建失败直接返回 | 
|---|
|  |  |  | if (Constants.equalsInteger(index,Constants.ONE) && StringUtils.equals(CreateDirecroty(remote, ftpClient), "2")) { | 
|---|
|  |  |  | log.error("创建ftp目录失败======================="+remote); | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | boolean result = ftpClient.storeFile(remoteFileName, inputStream); | 
|---|
|  |  |  | inputStream.close(); | 
|---|
|  |  |  | if(close){ | 
|---|
|  |  |  | ftpClient.logout(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(result){ | 
|---|
|  |  |  | log.info("上传文件成功======================"+remote); | 
|---|
|  |  |  | }else{ | 
|---|
|  |  |  | log.error("上传文件失败======================="+remote); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | log.error("上传文件失败======================="+remote); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return false; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public int getNumFromStr(String str,char searchstr) { | 
|---|
|  |  |  | int count = 0; | 
|---|
|  |  |  | char[] charArray = str.toCharArray(); | 
|---|