• 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
  • Ron McLeod
  • Junilu Lacar
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • Carey Brown
  • Stephan van Hulst
Bartenders:
  • Frits Walraven
  • fred rosenberger
  • salvin francis

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)

 
reply
    Bookmark Topic Watch Topic
  • New Topic