日期:2014-05-17 浏览次数:20834 次
<%
out.clear();
out = pageContext.pushBody();
response.setContentType("application/pdf");
try
{
String strPath = new String("E:\\velocity.pdf");
File file = new File(strPath);
if(file.exists())
{
//DataOutputStream temp = new DataOutputStream(response.getOutputStream());
//DataInputStream input = new DataInputStream(new FileInputStream(strPath));
InputStream input = new FileInputStream(strPath);
OutputStream temp = response.getOutputStream();
byte b[] = new byte[2048];
while((input.read(b)) != -1)
{
temp.write(b);
temp.flush();
}
input.close();
temp.close();
}
else
{
out.println("文件不存在!");
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>