Code example for Proxy

Methods: address, type

0
 
    static String toString(Proxy proxy) {
        if (proxy == Proxy.NO_PROXY)
            return "DIRECT"; 
        // java.net.Proxy only knows about http and socks proxies. 
        Proxy.Type type = proxy.type();
        switch (type) {
        case HTTP: return "PROXY " + proxy.address().toString();
        case SOCKS: return "SOCKS5 " + proxy.address().toString();
        case DIRECT: return "DIRECT";
        default: 
            // If a new proxy type is supported in future, add a case to match it. 
            fail("Unknown proxy type" + type);
            return "unknown://"; 
        } 
    } 
 
    static String toString(List<Proxy> proxies) {
        StringBuilder builder = new StringBuilder();
        for (Proxy proxy : proxies) {
            if (builder.length() > 0)