Server returned HTTP response code: 407
I am using WGet to access the content of few webpages as below:
String inputLine;
StringBuffer buffer = new StringBuffer();
System.setProperty("http.proxyHost", "myproxy.company.com");
System.setProperty("http.proxyPort", "8080");
System.setProperty("http.proxyUser", "username");
System.setProperty("http.proxyPassword", "password");
URL srcURL = new URL("http://www.example.com");
URLConnection connection = srcURL.openConnection();
connection.setConnectTimeout(60000);
connection.setReadTimeout(60000);
BufferedReader reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
while ((inputLine = reader.readLine()) != null) {
buffer.append(inputLine + System.getProperty("line.separator").toString());
}
reader.close();
return (buffer.toString().length() > 0) ? buffer.toString() : "";
While executing this code in Ubuntu machine, I get the below error:
java.io.IOException: Server returned HTTP response code: 407 for URL:
http://www.example.com/
at
sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1459)
How to resolve this error?
No comments:
Post a Comment