try {
FTPClient client = new FTPClient();
client.setDataTimeout(10000);
client.connect(park.getServerIP(), park.getServerFTPPort());
client.login(uname, psw);
InputStream in = null;
if (info.getLeavePicturePath() != null && !"".equals(info.getLeavePicturePath()) && client != null) {
in = client.retrieveFileStream(new String(URLDecoder.decode(info.getLeavePicturePath(), "utf-8").getBytes("GBK"), "iso-8859-1"));
}
if (in == null) {
in = client.retrieveFileStream(FTP路径转换("UTF-8"), "iso-8859-1"));
}
image = IOUtils.toByteArray(in);
client.logout();
client.disconnect();
} catch (Exception e) {
logger.error(">>>>>:" + e);
}
if (image == null || image.equals("")) {
String url = request.getSession().getServletContext().getRealPath("/");
image = image2byte(url + "images/NoTakePhota.jpg");
}
ServletOutputStream sout = response.getOutputStream();
sout.write(image, 0, image.length);
sout.flush();
sout.close(); // 关闭输入流
return null;
FTP数据读写简单示例
最新推荐文章于 2021-10-20 23:55:01 发布