标签:style blog class code c java
1 获取网站资源(重点) 2 public void doGet(HttpServletRequest request, HttpServletResponse response)throws ServletException, IOException { 3 // 获取网站对象 4 ServletContext context = this.getServletContext(); 5 // 获取网站中的静态资源 6 InputStream in = context.getResourceAsStream("/123.bmp"); 7 // 获取输出流 8 FileOutputStream out = new FileOutputStream(new File("d:/123.bmp")); 9 // 边读 边写 10 byte[] bs = new byte[1024]; 11 int len = 0; 12 while((len = in.read(bs)) != -1){ 13 out.write(bs, 0, len); 14 out.flush(); 15 } 16 // 释放资源 17 in.close(); 18 out.close(); 19 }
获取网站资源 getResourceAsStream,布布扣,bubuko.com
标签:style blog class code c java
原文地址:http://www.cnblogs.com/friends-wf/p/3729508.html