I can't get past our proxy server. Below is a test case that returns an HTTP 407 error ...
Exception in thread "main" java.io.IOException: Server returned HTTP response code: 407 for URL: http://www.google.com/
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:691)
at java.net.URL.openStream(URL.java:955)
at URLReader.main(URLReader.java:12)
I got the settings from my browser (IE6.0), except for the "proxyType" which was suggested in another thread. I have also read (and applied) the javaworld tip #42, but still no go. Any thoughts?
import java.net.*;
import java.io.*;
import java.util.*;
public class URLReader {
public static void main(String[] args) throws Exception {
// Configure proxy ...
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", "205.160.225.143");
System.setProperty("http.proxyPort", "80");
System.setProperty("http.proxyType", "4");
// Open URL ...
URL url = new URL("http://www.google.com/");
BufferedReader in = new BufferedReader (
new InputStreamReader (
url.openStream ()
)
);
// Read it ...
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}
}