Access the network through proxy

Source: Internet
Author: User

Connect to the network using proxy

@ Test public void t13 () {string charset = "UTF-8"; string proxyhost = "proxy address"; int proxyport = 1234; // proxy port string proxyursername = "Login Proxy Server Username"; string proxypassword = "Login proxy server password"; string urlstr = "http://www.baidu.com"; string ret = ""; inputstream is = NULL; try {proxy = new proxy (proxy. type. HTTP, new inetsocketaddress (proxyhost, proxyport); Url url = new URL (urlstr); httpurlc Onnection connection = (httpurlconnection) URL. openconnection (proxy); base64encoder encoder = new base64encoder (); string authorization = new string (encoder. encode (new string (proxyursername + ":" + proxypassword ). getbytes (); connection. setrequestproperty ("proxy-Authorization", "Basic" + authorization); connection. setdoinput (true); connection. setrequestmethod ("get"); connection. connect (); is = Co Nnection. getinputstream (); stringbuffer sb = new stringbuffer (); int RL =-1; byte [] Buf = new byte [1024]; while (RL = is. read (BUF ))! =-1) {sb. append (new string (BUF, 0, rl, charset);} ret = sb. tostring (); connection. disconnect ();} catch (malformedurlexception e) {e. printstacktrace ();} catch (ioexception e) {e. printstacktrace ();} finally {If (is! = NULL) {try {is. Close () ;}catch (ioexception e) {e. printstacktrace () ;}} system. Out. println (RET );}

How to bring up the IE proxy box when connecting to the network so that the user does not know how to implement the input?

I do not know how to obtain the IE proxy.

Access the network through proxy

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.