• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ArrayIndexOutOfBoundsException

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import java.net.*;
import javax.net.*;
import javax.net.ssl.*;
import java.io.*;
import org.apache.commons.codec.binary.Base64;
public class ReadHttpsURL1 {
public static void main(String argv[]) throws Exception {

System.setProperty("http.proxyHost", "proxy hostname");
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyUser", "proxy username");
System.setProperty("http.proxyPassword", "proxy password");
System.setProperty("https.proxyHost", "proxy hostname");
System.setProperty("https.proxyPort", "80");
System.setProperty("https.proxyUser", "proxy username");
System.setProperty("https.proxyPassword", "proxy password");
System.setProperty("proxySet", "true");
Authenticator.setDefault(new ProxyAuthenticator("proxy username", "proxy password"));
System.setProperty("http.proxySet", "true");
System.setProperty("https.proxySet", "true");


String encoded = new String(Base64.encodeBase64(("proxy username:proxy password").getBytes()));
URL url = new URL("https://www.google.com");
HttpsURLConnection uc =(HttpsURLConnection) url.openConnection();
uc.setRequestProperty("Proxy-Authorization","Basic "+encoded);
InputStream is = uc.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);

String line;
StringBuffer sb = new StringBuffer();
while((line = br.readLine()) != null) {
sb.append(line);
}
System.out.println(sb.toString());
}
}
run my code it throws below exception :

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at sun.net.www.protocol.http.NTLMAuthentication.buildType3Msg(NTLMAuthentication.java:368)
at sun.net.www.protocol.http.NTLMAuthentication.setHeaders(NTLMAuthentication.java:225)
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:1557)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1139)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
at ReadHttpsURL1.main(ReadHttpsURL1.java:29)

 
You guys wanna see my fabulous new place? Or do you wanna look at this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic