<%@page import="java.util.*"%> <%@page import="java.io.*"%> <%@page import="java.net.*"%> <html> <head> <title> qq </title> </head> <body bgcolor="#ffffff"> <% response.setContentType("application/ms-word"); BufferedInputStream bis = null; BufferedOutputStream bos = null; try { bis = new BufferedInputStream(new FileInputStream("D:\\myjava\\iptest\\WebModule1\\aaa.doc")); bos = new BufferedOutputStream(response.getOutputStream()); byte[] buff = new byte[2048]; int bytesRead; while ( -1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } } catch (final IOException e) { System.out.println("出现IOException." + e); } finally { if (bis != null) bis.close(); if (bos != null) bos.close(); }
%> </body> </html>
|