Here you can find the source of createProxy(final Proxy.Type type, final String host, final int port)
Parameter | Description |
---|---|
type | a parameter |
host | a parameter |
port | a parameter |
public static Proxy createProxy(final Proxy.Type type, final String host, final int port)
//package com.java2s; /******************************************************************************* * Copyright (c) 2007, 2013 compeople AG and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w . j av a2 s . com * compeople AG - initial API and implementation *******************************************************************************/ import java.net.InetSocketAddress; import java.net.Proxy; import java.net.SocketAddress; public class Main { /** * @param type * @param host * @param port * @return */ public static Proxy createProxy(final Proxy.Type type, final String host, final int port) { return new Proxy(type, InetSocketAddress.createUnresolved(host, port)); } /** * @param scheme * @param sa * @return */ public static Proxy createProxy(final String scheme, final SocketAddress sa) { final Proxy.Type type = resolveProxyType(scheme); return new Proxy(type, sa); } /** * @param protocol * @return */ public static Proxy.Type resolveProxyType(final String protocol) { if (protocol != null && (protocol.equalsIgnoreCase("socks") || protocol.equalsIgnoreCase("socket"))) { //$NON-NLS-1$ //$NON-NLS-2$ return Proxy.Type.SOCKS; } else { return Proxy.Type.HTTP; } } }