Reads a JSON object from the given metadata URL and generates a new Meta object containing all types.

@param url The API metadata URL.
@return Meta
966099
public static Meta fromUrl(URL url) {
        InputStream stream = null;
        try {
            stream = url.openStream();
            Gson gson = new GsonBuilder().registerTypeAdapter(PropertyForm.class, new TypeAdapter<PropertyForm>() {
                    @Override
                    public void write(JsonWriter out, PropertyForm value) throws IOException {
                        out.value(value.name().toLowerCase());
                    }

                    @Override
                    public PropertyForm read(JsonReader in) throws IOException {
                        return PropertyForm.valueOf(in.nextString().toUpperCase());
                    }
                }).create();
            Map<String, Type> types = gson.fromJson(
                    new InputStreamReader(stream),
                    new TypeToken<Map<String, Type>>(){ }.getType()
            );
            return new Meta(types);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (stream != null) {
                try { stream.close(); } catch (Exception e) { }
            }
        }
    }
162702
def _from_metadata(self, urlpath):
        """"""
        md = self.get_metadata(urlpath)
        if md is not None:
            return [self._path(urlpath)]
1045609
public static String readString(URL url, String charset) throws IORuntimeException {
		if (url == null) {
			throw new NullPointerException("Empty url provided!");
		}

		InputStream in = null;
		try {
			in = url.openStream();
			return IoUtil.read(in, charset);
		} catch (IOException e) {
			throw new IORuntimeException(e);
		} finally {
			IoUtil.close(in);
		}
	}
1211371
protected Map<String, String> readCredentialsURL(URL url) {
        Map<String, String> credentials = new HashMap<>();
        Pattern entry = Pattern.compile("^([^:]+):(.+)");
        try (Scanner scanner = new Scanner(url.openStream(), StandardCharsets.UTF_8.name())) {
            while (scanner.hasNextLine()) {
                String line = scanner.nextLine().trim();
                if (!line.isEmpty() && !line.startsWith("#")) {
                    Matcher m = entry.matcher(line);
                    if (m.matches()) {
                        String username = m.group(1);
                        String password = m.group(2);
                        if (Strings.isNullOrEmpty(username)) {
                            log.warn("Skipping line because the username is blank!");
                            continue;
                        }
                        if (Strings.isNullOrEmpty(password)) {
                            log.warn("Skipping '{}' account because the password is blank!", username);
                            continue;
                        }

                        credentials.put(username.trim(), password.trim());
                    }
                }
            }
        } catch (Exception e) {
            log.error("Failed to read {}", url, e);
        }
        return credentials;
    }
145121
public Object create(String url)
        throws MalformedURLException, ClassNotFoundException
    {
        HessianMetaInfoAPI metaInfo;

        metaInfo = (HessianMetaInfoAPI) create(HessianMetaInfoAPI.class, url);

        String apiClassName =
                (String) metaInfo._hessian_getAttribute("java.api.class");

        if (apiClassName == null)
            throw new HessianRuntimeException(url + " has an unknown api.");

        Class<?> apiClass = Class.forName(apiClassName, false, _loader);

        return create(apiClass, url);
    }
773128
@Nullable
  public ObjectRes getMeta(@NotNull final String hash) throws IOException {
    return doWork(auth -> doRequest(auth, new MetaGet(), AuthHelper.join(auth.getHref(), PATH_OBJECTS + "/" + hash)), Operation.Download);
  }
805179
public static String get(String url, Map<String, String> body) {
        return get(url, JSONObject.toJSONString(body));
    }
969449
public static HttpUrl parse(String url) {
        Builder builder = new Builder();
        Builder.ParseResult result = builder.parse(null, url);
        return result == Builder.ParseResult.SUCCESS ? builder.build() : null;
    }
632802
public static String readUrlContent( String url )
	throws IOException, URISyntaxException {

		InputStream in = null;
		try {
			URI uri = UriUtils.urlToUri( url );
			in = uri.toURL().openStream();
			ByteArrayOutputStream os = new ByteArrayOutputStream();

			Utils.copyStreamSafely( in, os );
			return os.toString( "UTF-8" );

		} finally {
			closeQuietly( in );
		}
	}
383208
protected function parseUri($url, $meta = [])
    {
        $uri = implode('/', array_slice($url['path'], 2));
        $queryString = '';

        if (!empty($queryParams = ($url['query'] ?? null))) {
            $queries = [];
            foreach ($queryParams as $query) {
                if (empty(preg_match('/^{/', $query['value']))) {
                    $query['value'] = '{' . $query['key'] . '}';
                }
                $queries[] = "{$query['key']}={$query['value']}";
            }
            if (!empty($queries)) {
                $queryString = '?' . implode('&', $queries);
            }
        }

        $uriFinal = $uri . $queryString;
        $uriFinal = $this->applyFilter('Uri', $uriFinal, $meta);
        return $uriFinal;
    }
120852
public static <T> T readUrlAsObject(String url, Class<T> type) {
		String contents = getUrlContents(url);
		ObjectMapper mapper = new ObjectMapper();
		mapper.enableDefaultTyping();

		try {
			return mapper.readValue(contents, type);
		} catch (IOException e) {
			JK.throww(e);
			return null;
		}
	}
73895
public String simpleGet(String url) throws IOException {
		final AtomicReference<String> str = new AtomicReference<>();
		simpleGetInternal(url, inputStream -> {
            try {
                str.set(IOUtils.toString(inputStream, "UTF-8"));
            } catch (IOException e) {
                throw new IllegalStateException(e);
            }
        }, null);

		return str.get();
	}
388036
public static String readContentAsString(URL url, String encoding) {
        try {
            return readContentAsString(url.openStream());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
1350752
protected static Properties loadConfig(URL url) {
    InputStream is = null;
    try {
      URLConnection connection = url.openConnection();
      if(connection instanceof HttpURLConnection) {
        HttpURLConnection conn = (HttpURLConnection)connection;
        conn.setConnectTimeout(5000);
        conn.setReadTimeout(5000);        
      }
      is = connection.getInputStream();
      return loadConfig(url.toString(), is);     
    } catch (Exception ex) {
      ex.printStackTrace(System.err);
      throw new IllegalArgumentException("Failed to load configuration from [" + url + "]", ex);
    }finally {
      if(is!=null) try { is.close(); } catch (Exception ex) { /* No Op */ }
    }
  }
379617
public static Properties loadProperties(URL url) {
        if (null == url) {
            return new Properties();
        }
        return loadProperties(inputStream(url));
    }
42801
public static Map<String, ? extends CacheConfig> fromJSON(URL url) throws IOException {
        return new CacheConfigSupport().fromJSON(url);
    }
562110
public static URL url(final String url) {
        if (url == null) {
            return null;
        }
        try {
            if (url.startsWith("classpath:")) {
                return new URL(null, url, new ClasspathURLStreamHandler());
            }
            return new URL(url);
        } catch (final MalformedURLException ex) {
            throw new IllegalArgumentException("Invalid URL: " + url, ex);
        }
    }