Java_设立HTTP代理

Java_设置HTTP代理
/**如果有代理设置所使用
	 * @param host 代理地址
	 * @param port 端口
	 * @param username 用户名
	 * @param password 密码
	 */
	public static void initProxy(String host, int port, final String username,final String password) {
		Authenticator.setDefault(new Authenticator() {
			protected PasswordAuthentication getPasswordAuthentication() {
				return new PasswordAuthentication(username,
						new String(password).toCharArray());
			}
		});
		System.setProperty("http.proxyPort", Integer.toString(port));
		System.setProperty("http.proxyHost", host);
	}