| | |
| | | if (!ftpClient.changeWorkingDirectory(basePath + filePath)) { |
| | | // 如果目录不存在创建目录 |
| | | String[] dirs = filePath.split("/"); |
| | | String tempPath = basePath; |
| | | String tempPath = ""; |
| | | for (String dir : dirs) { |
| | | if (null == dir || "".equals(dir)) |
| | | if (null == dir || "".equals(dir)) { |
| | | continue; |
| | | } |
| | | tempPath += "/" + dir; |
| | | if (!ftpClient.changeWorkingDirectory(tempPath)) { |
| | | if (!ftpClient.makeDirectory(tempPath)) { |
| | |
| | | LOCAL_CHARSET = "UTF-8"; |
| | | } |
| | | ftpClient.setControlEncoding(LOCAL_CHARSET); |
| | | ftpClient.enterLocalPassiveMode();// 设置被动模式 |
| | | ftpClient.setFileType(FTP.BINARY_FILE_TYPE);// 设置传输的模式 |
| | | // 设置被动模式 |
| | | ftpClient.enterLocalPassiveMode(); |
| | | // 设置传输的模式 |
| | | ftpClient.setFileType(FTP.BINARY_FILE_TYPE); |
| | | // 上传文件 |
| | | filename = new String(filename.getBytes(LOCAL_CHARSET), SERVER_CHARSET); |
| | | if (!ftpClient.storeFile(filename, input)) { |
| | |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", "q"+response1+".json", in1); |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpBasePath, ftpFilePath, "q"+response1+".json", in1); |
| | | MysqlCenlint.deletess("q"+response1+".json"); |
| | | } |
| | | |
| | |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpPath, "/", "w"+response1+".json", in1); |
| | | FtpUtil.uploadFile(ftpHost, ftpPort, ftpUserName, ftpPassword, ftpBasePath, "/", "w"+response1+".json", in1); |
| | | MysqlCenlint.deletess("w"+response1+".json"); |
| | | } |
| | | |