JAVA读取本地图片并展示

代码如下:

//读取本地图片输入流
FileInputStream inStream = new FileInputStream("D:/image/123.jpg");

//byte数组用于存放图片字节数据
byte[] buff = new byte[inSteam.available()];

inStream.read(buff);
inStream.close();

//设置发送到客户端的响应内容类型
response.setContentType("image/*");

OutputStream outStream = response.getOutputStream();
out.write(buff);
out.close();

你可能感兴趣的:(java)