File file = new File(fileName); InputStream fis = new BufferedInputStream(new FileInputStream(fileName)); byte[] buffer = new byte[fis.available()]; fis.read(buffer); fis.close(); // 清空response response.reset(); BufferedInputStream br = new BufferedInputStream(new FileInputStream(file)); byte[] buf = new byte[1024]; int len = 0; // 純下載方式 response.setHeader("Content-Disposition", "attachment; filename=" + dis.getTitle()+".zip"); OutputStream out = response.getOutputStream(); while ((len = br.read(buf)) > 0){ out.write(buf, 0, len); } br.close(); out.close();