Here you can find the source of buildUrlsList(final String domain, final String... paths)
Parameter | Description |
---|---|
domain | the base domain for the given paths |
paths | an array of paths to relative to the base domain |
private static List<URL> buildUrlsList(final String domain, final String... paths)
//package com.java2s; //License from project: Open Source License import java.net.MalformedURLException; import java.net.URL; import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; public class Main { /**//ww w . ja v a 2s . co m * Builds a {@link List} of {@link URL}s given a domain and 1..N paths relative to the domain. * * @param domain the base domain for the given {@code paths} * @param paths an array of paths to relative to the base {@code domain} * @return a {@link List} of {@link URL}s */ private static List<URL> buildUrlsList(final String domain, final String... paths) { return Arrays.stream(paths).map(p -> buildUrl(domain, p)).collect(Collectors.toList()); } /** * Builds an {@link URL} given a domain and a path. * * @param domain the domain * @param path the path * @return the {@link URL} */ private static URL buildUrl(final String domain, final String path) { try { return new URL(new URL(domain), path); } catch (MalformedURLException e) { throw new RuntimeException(e); } } }