public String downloadFile(String url) throws HttpException {
		String filePath = null;
		// 1.生成 HttpClinet 对象并设置参数
		CloseableHttpClient httpclient = HttpClients.createDefault();
		// 设置 HTTP 连接超时 5s
		RequestConfig requestConfig = RequestConfig.custom()
				.setConnectionRequestTimeout(5000).setConnectTimeout(5000)
				.setSocketTimeout(5000).build();
		// 2.生成 GetMethod 对象并设置参数
		HttpGet httpGet = new HttpGet(url);
		httpGet.setConfig(requestConfig);
		System.out.println("Executing request " + httpGet.getRequestLine());
		// 设置 get 请求超时 5s
		// getMethod.getParams().setParameter(HttpMethodParams.SO_TIMEOUT,
		// 5000);
		// 设置请求重试处理
		// getMethod.getParams().setParameter(HttpMethodParams.RETRY_HANDLER,
		// new DefaultHttpMethodRetryHandler());
		// 3.执行 HTTP GET 请求
		try {		
			CloseableHttpResponse response = httpclient.execute(httpGet);
			int status = response.getStatusLine().getStatusCode();
			
			if (status >= 200 && status < 300) {
				HttpEntity entity = response.getEntity();
				String context = entity != null ? EntityUtils.toString(entity)
						: null;
				filePath = "temp/"
						+ getFileNameByUrl(url, response.getHeaders(
						"Content-Type")[0].getValue());
				saveToLocal(context.getBytes(), filePath);
			} else {
				throw new ClientProtocolException(
						"Unexpected response status: " + status);
			}

		} catch (IOException e) {
			// 发生网络异常
			e.printStackTrace();
		} finally {
			// 释放连接
			try {
				httpclient.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return filePath;
	}