title: proxy host name,port,username,password with httpurlconnection
body: <pre><code>private static void setProxy(String proxyHostName,int proxyport){
      proxy=new Proxy(Proxy.Type.HTTP,new InetSocketAddress(proxyHostName,proxyport));
  }
  
  private static void setProxy(String proxyHostName,int proxyport,String username,String password){
      setProxy(proxyHostName,proxyport);
      if (username!=null &amp;&amp; password!=null) {
          Authenticator authenticator = new Authenticator() {
  
              public PasswordAuthentication getPasswordAuthentication() {
                  return (new PasswordAuthentication(username, password.toCharArray()));
              }
          };
          Authenticator.setDefault(authenticator);
      }
  
  }
  </code></pre>
  
  <p>this is code for proxy setting.I don't know why it's throwing this error.</p>
  
  <p>exception:</p>
  
  <p>java.io.IOException: Unable to tunnel through proxy. Proxy returns ""HTTP/1.1 407 Proxy Authentication Required""
      at sun.net.<a href="http://www.protocol.http.httpurlconnection.dotunneling%28httpurlconnection.java:2142/" rel="nofollow noreferrer">http://www.protocol.http.httpurlconnection.dotunneling%28httpurlconnection.java:2142/</a>)
      at sun.net.<a href="http://www.protocol.https.abstractdelegatehttpsurlconnection.connect%28abstractdelegatehttpsurlconnection.java:183/" rel="nofollow noreferrer">http://www.protocol.https.abstractdelegatehttpsurlconnection.connect%28abstractdelegatehttpsurlconnection.java:183/</a>)
      at sun.net.<a href="http://www.protocol.https.httpsurlconnectionimpl.connect%28httpsurlconnectionimpl.java:162/" rel="nofollow noreferrer">http://www.protocol.https.httpsurlconnectionimpl.connect%28httpsurlconnectionimpl.java:162/</a>)
  ..</p>