aspose file tools*
The moose likes Websphere and the fly likes ArrayIndexOutOfBoundsException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Products » Websphere
Bookmark "ArrayIndexOutOfBoundsException" Watch "ArrayIndexOutOfBoundsException" New topic
Author

ArrayIndexOutOfBoundsException

krish dutt
Greenhorn

Joined: Feb 23, 2012
Posts: 5
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)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ArrayIndexOutOfBoundsException
 
Similar Threads
Unable to tunnel through proxy. Proxy returns "HTTP/1.0 407 Proxy Authentication Requ
Unable to tunnel through proxy. Proxy returns "HTTP/1.0 407 Proxy Authentication Requ
having trouble with reading source of secure page
HttpsURLConnection - Problem in SSL Handshaking
Communicating with HTTPS server with Client Authentication