protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { //设置响应文本类型 response.setContentType("image/jpeg"); //获取输出流 InputStream in=this.getClass().getClassLoader().getResourceAsStream("girl.jpg"); //在读写操作前先获得数据流的总长 int len= 0; while (len==0) { len=in.available(); } byte[] buffer=new byte[len]; in.read(buffer); }
After reading a picture than out a picture.
If opportunity doesn’t knock, build a door