使用servlet输出word文档

try  {
            resp.setContentType(
" application/msword " );
            //resp.setHeader(
" Content-disposition " , " attachment;filename=Example.doc " ); //下载用
            File f0 
=   new  File( " c:/example.doc " );
            
byte [] b0  =  Byte_File_Object.getBytesFromFile(f0);
            BufferedOutputStream  dataOut 
=   new  BufferedOutputStream(resp.getOutputStream());  
            dataOut.write(b0,
0 ,b0.length); 
            
if  (dataOut != null ) {
                dataOut.close();
            }
        } 
catch  (Exception e) {
            e.printStackTrace();
        }
 

你可能感兴趣的:(c,servlet,File,null,文档,byte)