Download PDF file from seven KN service

Source: Internet
Author: User

/*** Download PDF file from seven kn *@paramRequest *@paramResponse *@paramExhiid *@throwsmalformedurlexception*/@RequestMapping ("/loadcanzhanhan")     Public voidDownloadnet (httpservletrequest request, HttpServletResponse response,string exhiid)throwsmalformedurlexception{exhimain Exhimain=Exhimainservice.get (EXHIID); String Canzhanhanurl=Exhimain.getcanzhanhanurl (); Try {            if(Canzhanhanurl! =NULL&& "". Equals (Canzhanhanurl))            {Pdfutil.downloadzhaozhanhan (response, Canzhanhanurl); }                    } Catch(Exception e) {e.printstacktrace (); }               }
/*** Download the pdf file above seven kn *@paramResponse *@paramCanzhanhanurl Seven the file address on the bull *@throwsException*/     Public Static voidDownloadzhaozhanhan (HttpServletResponse response,string canzhanhanurl)throwsexception{intByteread=0; URL URL=NewURL (Canzhanhanurl); Try{URLConnection conn=url.openconnection (); InputStream instream=Conn.getinputstream (); Servletoutputstream OutputStream=Response.getoutputstream (); Response.setheader ("Content-disposition", "attachment;filename=" + Urlencoder.encode ("brochure. pdf", "UTF-8")); Response.setcontenttype ("Application/force-download"); byte[] buffer =New byte[1024];  while(Byteread=instream.read (buffer))!=-1) {outputstream.write (buffer,0, Byteread); }        } Catch(Exception e) {e.printstacktrace (); }            }

Download PDF files from seven KN service

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.