FSClient { public ComFile downloadFile(Long fileId) { ComFile comFile = new ComFile(); ComFSFile comFSFile = comFSRemoteService.selectComFSFileById(fileId); if (comFSFile != null) { Long fsId = comFSFile.getFsId(); comFile.setFileName(comFSFile.getFileName()); comFile.setFileData(new byte[0]); FTPClient ftpClient = connectServer(fsId); if (ftpClient != null) { try { if (ftpClient.changeWorkingDirectory(comFSFile.getFilePath())) { FTPFile[] fs = ftpClient.listFiles(); for (FTPFile ff : fs) { if (ff.getName().equals(comFSFile.getServerFileName())) { OutputStream os = new ByteArrayOutputStream(); ftpClient.retrieveFile(new String(ff.getName().getBytes("UTF-8"), "ISO-8859-1"), os); ByteArrayOutputStream bos = (ByteArrayOutputStream) os; comFile.setFileData(bos.toByteArray()); comFile.setOutputStream(os); os.close(); bos.close(); ftpClient.logout(); ftpClient.disconnect(); logger.info("Download file : fileId " + fileId + " success!"); return comFile; } } } else { logger.error("cd dir " + comFSFile.getFilePath() + " failed!"); } } catch (Exception e) { logger.error(e); } } } else { logger.error("File does't exist FileId is " + fileId); } return comFile; }  Long uploadFile(String fileName, InputStream inputStream, String serverType,String subFolder); Long uploadFile(String fileName, InputStream inputStream, String serverType); Long uploadFile(String fileName, byte[] fileData, String serverType); Long uploadFile(File localFile, String serverType); ComFile downloadFile(Long fileId); ComFile downloadFile(final Long fsId,final String dirName,final String filePath,final String fileName); ComFSService getComFSRemoteService(); void setComFSRemoteService(ComFSService comFSRemoteService);  }
@Test public void testDownloadFile() { Long pkId = uploadFile(); ComFile comFile = fsClient.downloadFile(pkId); System.out.println("testDownloadFile 文件名称为： " + comFile.getFileName()); Assert.assertNotNull(comFile.getFileName()); }