How to deal with this PrtocolException
i am trying to write a very basic code that opens a url and reads it.
i am working under a password protected proxy server
here is the code:
import java.net.*;
import java.io.*;
publicclass URLReader{
publicstaticboolean bool =true;
publicstaticvoid main(String[] args)throws Exception{
try{
dummy dum =new dummy();
dum.setAuth();
URL yahoo =new URL("http://www.yahoo.com/");
BufferedReader in =new BufferedReader(
new InputStreamReader(
yahoo.openStream()));
String inputLine;
while ((inputLine = in.readLine()) !=null)
System.out.println(inputLine);
in.close();
}catch (UnknownHostException e){
System.out.println(e.toString());
}catch (IOException e){
System.out.println(e.toString());
}
}
}
class dummy{
publicvoid setAuth(){
Authenticator.setDefault(new MyAuthenticator());
}
}
class MyAuthenticatorextends Authenticator{
protected PasswordAuthentication getPasswordAuthentication(){
String password =new String("password");
returnnew PasswordAuthentication("username", password.toCharArray());
}
}
the username and password i use are the real ones that i have replaced here
on running with
java -Dhttp.proxyHost=proxyhost
[-Dhttp.proxyPort=portNumber] URLReader
type of command
i get the following exception
java.net.ProtocolException: Server Redirected too many times(20)
can anybody help me out

