文件下载

public ModelAndView downloadFile(HttpServletRequest request,
  HttpServletResponse response) throws Exception{
 String filename = request.getParameter("filename");
 String sfz = request.getParameter("sfz");
 if(filename==null )
 {
  filename="";
 }
    String filepath ="d:/File/"+sfz+"/"+filename;
 File file=new File(filepath); 
 if(file.exists())
 {
  InputStream is =  new FileInputStream(file);
  FileManager.downloadFile(response, filename, is);
  is.close();
 }
 return null; 
}

你可能感兴趣的:(文件下载)