public class Download extends HttpServlet
{
public void doget (HttpServletRequest request, httpservletresponse response) throws IOException, Servletexception
{
Try
{
There's something else you can do.
Response.setcontenttype ("Application/octet-stream");
Response.setheader ("Content-disposition", "attachment; Filename=\ "The Save file name you want to display in the Save Window \");
Servletoutputstream out = Response.getoutputstream ();
BufferedReader br=new BufferedReader (new FileReader (file name to be downloaded));
Moderator Tips: The code here is a problem when doing a binary file download, because the BufferedReader is used here, and this class is prepared for reading "characters" and needs to be read by "byte", please use InputStream.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.