可以设置http和socks代理的。如下:
System.getProperties().setProperty( "socksProxyHost",socksProxyHost);
System.getProperties().setProperty( "socksProxyPort",socksProxyPort);
System.getProperties().setProperty( "http.proxyHost",httpProxyHost);
System.getProperties().setProperty( "http.proxyPort",httpProxyPort);然后设置用户名和密码:
public  class MyAuthenticator extends Authenticator
{
private String username,password; public MyAuthenticator(String username,String password)
{
this.username=username;
this.password=password;
} protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication(username,password.toCharArray());
}
}//end MyAuthenticator验证用户名和密码:
Authenticator.setDefault( new MyAuthenticator( username,password ) );