通过HTTP GET方式下载文件到指定的目录。

@param url 需要下载的URL
@param toDir 需要下载到的目录
@return 下载后的文件
502603
public static File download(String url, File toDir) throws AlipayApiException {
		toDir.mkdirs();
		HttpURLConnection conn = null;
		OutputStream output = null;
		File file = null;
		try {
			conn = getConnection(new URL(url));
			String ctype = conn.getContentType();
			if (CTYPE_OCTET.equals(ctype)) {
				String fileName = getFileName(conn);
				file = new File(toDir, fileName);
				output = new FileOutputStream(file);
				copy(conn.getInputStream(), output);
			} else {
				String rsp = WebUtils.getResponseAsString(conn);
                throw new AlipayApiException(rsp);
			}
		} catch (IOException e) {
            throw new AlipayApiException(e.getMessage());
		} finally {
			closeQuietly(output);
			if (conn != null) {
				conn.disconnect();
			}
		}
		return file;
	}
119727
public static Map<String, List<String>> getResponseHeaders(String stringUrl) throws IOException {
    return getResponseHeaders(stringUrl, true);
  }
515152
private String getFullUrl(String url) {
        return url.startsWith("https://") || url.startsWith("http://") ? url : transloadit.getHostUrl() + url;
    }
331356
private static File getFile(URL resourceUrl) {
    try {
      return new File(new URI(resourceUrl.toString()).getPath());
    } catch (URISyntaxException e) {
      throw new RuntimeException(e);
    } catch (NullPointerException npe) {
      LOG.error("NullPointerException is thrown. Resource url: {} ", resourceUrl);
      throw new RuntimeException(npe);
    }
  }
932844
public JSONObject get(String url, HashMap<String, String> params) throws JSONException {
		return sendGetRequest(url, METHOD_GET, params);
	}
404407
public static String getUrlExtension(String url) {
        String extension = MimeTypeMap.getFileExtensionFromUrl(url);
        return TextUtils.isEmpty(extension) ? "" : extension;
    }
1031506
public ParallelTaskBuilder prepareHttpGet(String url) {
        reinitIfClosed();
        ParallelTaskBuilder cb = new ParallelTaskBuilder();
        
        cb.getHttpMeta().setHttpMethod(HttpMethod.GET);
        cb.getHttpMeta().setRequestUrlPostfix(url);
        
        return cb;
    }
155326
public HttpResponse doHttpGet(String url, Map<String, Object> headers, boolean followRedirect) {
        HttpResponse response = new HttpResponse();
        doGet(url, response, headers, followRedirect);
        return response;
    }
48980
public static String get(String url, Map<String, String> customHeaders, Map<String, String> params) throws URISyntaxException, IOException, HTTPException {
        LOGGER.log(Level.INFO, "Sending GET request to the url {0}", url);

        URIBuilder uriBuilder = new URIBuilder(url);

        if (params != null && params.size() > 0) {
            for (Map.Entry<String, String> param : params.entrySet()) {
                uriBuilder.setParameter(param.getKey(), param.getValue());
            }
        }

        HttpGet httpGet = new HttpGet(uriBuilder.build());

        populateHeaders(httpGet, customHeaders);

        HttpClient httpClient = HttpClientBuilder.create().build();

        HttpResponse httpResponse = httpClient.execute(httpGet);

        int statusCode = httpResponse.getStatusLine().getStatusCode();
        if (isErrorStatus(statusCode)) {
            String jsonErrorResponse = EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
            throw new HTTPException(statusCode, httpResponse.getStatusLine().getReasonPhrase(), jsonErrorResponse);
        }

        return EntityUtils.toString(httpResponse.getEntity(), StandardCharsets.UTF_8);
    }
20705
public static byte[] getBytes(URL url) throws IOException {
        final String path = url.getPath();
        final File file = new File(path);
        if (file.exists()) {
            return getFileBytes(file);
        }

        return null;
    }
988294
public String get(Context context, String url) {
        final Cursor cursor = context.getContentResolver().query(getUri(OfflinerDBHelper.TABLE_CACHE),
                OfflinerDBHelper.PARAMS_CACHE, OfflinerDBHelper.REQUEST_URL
                        + " = '" + url + "'", null, null);
        String result = null;

        if (cursor != null) {
            if (cursor.getCount() != 0) {
                cursor.moveToFirst();
                result = cursor.getString(cursor.getColumnIndex(OfflinerDBHelper.REQUEST_RESULT));
            }
            cursor.close();
        }

        return result;
    }
1043944
private static String fetchHttpResponse(URL url) throws IOException {
      HttpURLConnection conn = null;
      try {
         logger.info("fetching from url = " + url);
         conn = (HttpURLConnection) url.openConnection();
         int response = conn.getResponseCode();
         if (response != HttpURLConnection.HTTP_ACCEPTED) {
            String responseContent = IOUtils.toString(conn.getInputStream());
            logger.info("responseContent = " + responseContent);
            
            return responseContent;
         }
         throw new IOException("response from service not valid");
      } catch (IOException e) {
         logger.severe("unable to do proper http request url = " + url.toString());
         throw e;
      } finally {
         conn.disconnect();
      }

   }
1257581
public static URL getURL(File file) {
		Assert.notNull(file, "File is null !");
		try {
			return file.toURI().toURL();
		} catch (MalformedURLException e) {
			throw new UtilException(e, "Error occured when get URL!");
		}
	}
1180807
protected BaseResponse executeGet(String url) {
        BaseResponse response;
        BeanUtil.requireNonNull(url, "url is null");
        //需要传token
        String getUrl = url.replace("#", config.getAccessToken());
        response = NetWorkCenter.get(getUrl);
        return response;
    }
488551
public RFuture<String> get(String url) {
    return req(url).execute().map(GET_PAYLOAD);
  }
982633
public static String get(String url, String params) throws IOException {
        return HttpUtil.get(url, null, params);
    }
670003
private String get(String urlS) throws IOException {
        URL url = new URL(urlS);
        HttpURLConnection conn = prepareAuthorizedConnection(url);
        conn.setRequestMethod("GET");
        // Read response
        StringBuilder result = new StringBuilder();
        try (BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
            String line;
            while ((line = rd.readLine()) != null) {
                result.append(line);
            }
        }
        return result.toString();
    }