Read config objects stored in YAML format from <code>URL</code>

@param url of config
@return config
@throws IOException error
762402
public static Map<String, ? extends CacheConfig> fromYAML(URL url) throws IOException {
        return new CacheConfigSupport().fromYAML(url);
    }
768728
public static JarFile getJarFile(URL url) {
		try {
			JarURLConnection urlConnection = (JarURLConnection) url.openConnection();
			return urlConnection.getJarFile();
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
721571
public static BufferedImage read(URL imageUrl) {
		try {
			return ImageIO.read(imageUrl);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		}
	}
413557
private List<String> loadRenameFile(URL url) throws IOException {
        List<String> lines = new ArrayList<String>();
        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), Charset.forName("UTF-8")));
        try {
            String line;
            while ((line = reader.readLine()) != null) {
                String trimmed = line.trim();
                if (!trimmed.isEmpty() && !trimmed.startsWith("#")) {
                    lines.add(trimmed);
                }
            }
        } finally {
            reader.close();
        }
        return lines;
    }
99818
public static String sha1(URL url) {
		InputStream is = null;
		try {
			is = url.openStream();
			return sha1(is);
		} catch (IOException ioe) {
			log.warn("Error occourred while reading from URL: " + url, ioe);
			throw new RuntimeIOException(ioe);
		} finally {
			if (is != null) {
				try {
					is.close();
				} catch (IOException ioe) {
					log.warn("Failed to close stream for URL: " + url, ioe);
					throw new RuntimeIOException(ioe);
				}
			}
		}
	}
382340
public static String get(String url, Map<String, String> headers) throws IOException {
        return HttpUtil.get(url, headers, "");
    }
120824
public static String get(String url,
                             Map<String, String> headers,
                             Map<String, String> params) throws IOException {

        // 参数
        if (params != null && !params.isEmpty())
            url += "?" + Utils.getUrlParamsByMap(params);

        HttpURLConnection httpUrlConn = httpUrlConn(url);
        httpUrlConn.setDoInput(true);
        httpUrlConn.setRequestMethod(Constant.RequestMethodGet);

        // header
        if (headers != null && !headers.isEmpty())
            header(headers, httpUrlConn);

        httpUrlConn.connect();

        return readIO(httpUrlConn);
    }
445296
public static RunSet readRunSet(final URL url) throws IOException {
        checkNotNull(url);
        try (BufferedReader reader = Resources.asCharSource(url, Charsets.UTF_8).openBufferedStream()) {
            return readRunSet(reader);
        }
    }
474944
public static Program parse(URL url) throws IOException {
    InputStream in = url.openStream();
    try {
      return TerminalParser.parse(
          program(), new InputStreamReader(in, Charset.forName("UTF-8")), url.toString());
    } finally {
      in.close();
    }
  }
1199293
private void readConfigFromFile(URL file) throws IOException {
        FOKLogger.info(Config.class.getName(), "Reading config from local file...");
        InputStream inputStream = file.openStream();
        offlineProps.load(inputStream);
        inputStream.close();
    }
561194
public static URLConnection open(URL url) throws IOException {
        final ProxyConfiguration p = get();
        
        URLConnection con;
        if(p==null) {
            con = url.openConnection();
        } else {
            Proxy proxy = p.createProxy(url.getHost());
            con = url.openConnection(proxy);
            if(p.getUserName()!=null) {
                // Add an authenticator which provides the credentials for proxy authentication
                Authenticator.setDefault(p.authenticator);
                p.jenkins48775workaround(proxy, url);
            }
        }
        
        if(DEFAULT_CONNECT_TIMEOUT_MILLIS > 0) {
            con.setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS);
        }
        
        if (JenkinsJVM.isJenkinsJVM()) { // this code may run on a slave
            decorate(con);
        }

        return con;
    }
1060719
public DocumentSource createDocumentSource(URL url) throws IOException
    {
        try
        {
            Constructor<? extends DocumentSource> constr = getDocumentSourceClass().getConstructor(URL.class);
            return constr.newInstance(url);
        } catch (Exception e) {
            Throwable cause = e; //find if there is an IOException cause and throw it
            while (cause != null && !(cause instanceof IOException))
                cause = e.getCause();
            if (cause != null && cause instanceof IOException)
                throw (IOException) cause;
            //no IO exception cause, this should not happen (some internal reflection problem)
            log.error("Could not create the DocumentSource instance: " + e.getMessage());
            e.printStackTrace();
            return null;
        }
    }
217689
public static ReadableByteChannel getInstance(URL url) throws IOException
    {
        ProtocolHandler ph = map.get(url.getProtocol());
        if (ph != null)
        {
            return ph.create(url);
        }
        else
        {
            return Channels.newChannel(url.openStream());
        }
    }
877585
public Document readDocument(String url) {
        try {
            URL theURL = new URL(url);
            URLConnection conn = connectWithRedirect(theURL);
            if (conn == null)
                return null;

            ProvFormat format = null;
            String content_type = conn.getContentType();

            logger.debug("Content-type: " + content_type);
            if (content_type != null) {
                // Need to trim optional parameters
                // Content-Type: text/plain; charset=UTF-8
                int end = content_type.indexOf(";");
                if (end < 0) {
                    end = content_type.length();
                }
                String actual_content_type = content_type.substring(0, end)
                        .trim();
                logger.debug("Found Content-type: " + actual_content_type);
                // TODO: might be worth skipping if text/plain as that seems
                // to be the
                // default returned by unconfigured web servers
                format = mimeTypeRevMap.get(actual_content_type);
            }
            logger.debug("Format after Content-type: " + format);

            if (format == null) {
                format = getTypeForFile(theURL.toString());
            }
            logger.debug("Format after extension: " + format);

            InputStream content_stream = conn.getInputStream();

            return readDocument(content_stream, format,url);
        } catch (IOException e) {
            throw new InteropException(e);
        }
    }
615686
public static byte[] readBytes(URL url) throws IOException {
        URLConnection conn = url.openConnection();
        try {
            return readBytes(conn);
        } finally {
            close(conn);
        }
    }
1152285
public static Reader getReader(final URL url, String encoding) throws IOException {
        InputStream stream;
        try {
            stream = AccessController.doPrivileged(
                    new PrivilegedExceptionAction<InputStream>() {
                        @Override
                        public InputStream run() throws IOException {
                            InputStream is = null;
                            if (url != null) {
                                URLConnection connection = url.openConnection();
                                if (connection != null) {
                                    // Disable caches to get fresh data for reloading.
                                    connection.setUseCaches(false);
                                    is = connection.getInputStream();
                                }
                            }
                            return is;
                        }
                    }
            );
        } catch (PrivilegedActionException e) {
            throw (IOException)e.getException();
        }

        Reader reader;
        if (encoding != null) {
            reader = new InputStreamReader(stream, encoding);
        } else {
            reader = new InputStreamReader(stream);
        }
        return reader;
    }
859073
public static Config fromYAML(Reader reader) throws IOException {
        ConfigSupport support = new ConfigSupport();
        return support.fromYAML(reader, Config.class);
    }