标签:byte rac buffer message last tty fileinput trace void
读取图片
@GetMapping("uploadHeader/{fileName}")
public void getHeader(@PathVariable("fileName")String fileName,HttpServletResponse response){
//服务器存放路径
fileName=uplodePath+"/"+fileName;
//文件后缀
String suffix=fileName.substring(fileName.lastIndexOf("."));
//响应图片
response.setContentType("image/"+suffix);
try {
OutputStream os=response.getOutputStream();
FileInputStream file=new FileInputStream(fileName);
byte[] buffer=new byte[1024];
int b=0;
while ((b=file.read(buffer)) !=-1){
os.write(buffer,0,b);
}
} catch (IOException e) {
logger.error("读取失败"+e.getMessage());
e.printStackTrace();
}
}
标签:byte rac buffer message last tty fileinput trace void
原文地址:https://www.cnblogs.com/wesoul/p/14102808.html