@RequestMapping(value = "/readImage")
public void readImage(HttpServletResponse response) throws IOException {
String fileName = "D:/test.jpg";
File file = new File(fileName);
if(!(file.exists() && file.canRead())){
System.out.println("eee");
}
FileInputStream inputStream = new FileInputStream(file);
byte[] data = new byte[(int)file.length()];
int length = inputStream.read(data);
inputStream.close();
response.setContentType("image/png");
OutputStream stream = response.getOutputStream();
stream.write(data);
stream.flush();
stream.close();
}
public void readImage(HttpServletResponse response) throws IOException {
String fileName = "D:/test.jpg";
File file = new File(fileName);
if(!(file.exists() && file.canRead())){
System.out.println("eee");
}
FileInputStream inputStream = new FileInputStream(file);
byte[] data = new byte[(int)file.length()];
int length = inputStream.read(data);
inputStream.close();
response.setContentType("image/png");
OutputStream stream = response.getOutputStream();
stream.write(data);
stream.flush();
stream.close();
}