//读取pdf文件
super.getResponse().setContentType(“application/pdf”);
File file = null;
try{
String strPdfPath = fileName;
file = new File(strPdfPath);
if(file.exists()){
DataOutputStream temps = new DataOutputStream(super.getResponse().getOutputStream());
DataInputStream in = new DataInputStream(new FileInputStream(strPdfPath));
byte[] b = new byte[2048];
while((in.read(b))!=-1){
temps.write(b);
temps.flush();
}
in.close();
temps.flush();
}else{
System.out.print(strPdfPath + “文件不存在”);
}
}catch(Exception e){
System.out.println(e.getMessage());
}finally{
if(file!=null&&“Y”.equals(enabled)) file.delete();
}