执行CookiePolicy
import java.net.*; /**来自 n o w j a v a . c o m**/ public class BlacklistCookiePolicy implements CookiePolicy { String[] blacklist; public BlacklistCookiePolicy(String[] list) { blacklist = list; } public boolean shouldAccept(URI uri, HttpCookie cookie) { String host; try { host = InetAddress.getByName(uri.getHost()) .getCanonicalHostName(); } catch (UnknownHostException e) { host = uri.getHost(); } for (int i = 0; i < blacklist.length; i++) {// 来 自 n o w j a v a . c o m - 时 代 Java if (HttpCookie.domainMatches(blacklist[i], host)) { return false; } } return CookiePolicy.ACCEPT_ORIGINAL_SERVER .shouldAccept(uri, cookie); } }