从ftp获取文件
//获取ftp图片
@ResponseBody
public String getFtpImage ( ) throws InterruptedException {
ParamDTO dto = getDto();
String yke015 = request.getParameter(“yke015”);
//创建FTP连接
FTPClient ftp = null;
OutputStream outStream = null;
InputStream in = null;
try {
ftp= initFTP(ftp);
//下载文件
String path = (String) getDao().queryForObject(“zcjyhf.getPath”, yke015);
String fileName = “”;
String filepath = “/data/sftp/ncybj”+path;
FTPFile[] file = ftp.listFiles(filepath);
for (FTPFile s:file){
fileName = s.getName();//获取文件名
break;
}
in = ftp.retrieveFileStream(filepath+fileName);
String picType = filepath.split("\.")[1];
BufferedImage bufImg = null;
bufImg = ImageIO.read(in);
outStream = response.getOutputStream();
ImageIO.write(bufImg
从ftp获取图片
最新推荐文章于 2021-11-16 20:00:00 发布