-
/**
* 下载ftp不动产登记平台图片
* @param remotePath
* @param fileName
* @param bytes
* @return
*/
public byte[] downFile(String remotePath,String fileName,byte [] bytes) {
try {
int reply;
ftpClient.connect(ftpAddress,Integer.parseInt(ftpPort));
// 如果采用默认端口,可以使用ftp.connect(url)的方式直接连接FTP服务器
ftpClient.login(ftpUsername, ftpPassword);// 登录
reply = ftpClient.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
ftpClient.disconnect();
return bytes;
}
ftpClient.changeWorkingDirectory(remotePath);// 转移到FTP服务器目录
//下载指定文件
InputStream is = ftpClient.retrieveFileStream(fileName);
bytes = is2byte(is);
return bytes;
} catch (IOException e) {
e.printStackTrace();
} finally {// inputstream转byte[] private byte[] is2byte(InputStream is) throws IOException