0

Javaプロキシクラスを使用して、それをHttpURLConnection.openConnection()に渡します。
Proxyクラスに認証情報(http.proxyUserやhttp.proxyPasswordのように)を提供する方法はありますか?
ありがとう

4

1 に答える 1

2

その目的でAuthenticatorを使用できます。

Authenticator.setDefault(new Authenticator() {

        @Override
        protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("login", "password".toCharArray());
        }
});
于 2012-05-23T10:30:58.177 に答える