Java Utililty Methods URL Load

List of utility methods to do URL Load

Description

The list of methods to do URL Load are organized into topic(s).

Method

MapreadMappingFile(final URL filename)
read Mapping File
final Map<String, String> ret = new HashMap<String, String>();
try {
    BufferedReader in = new BufferedReader(new InputStreamReader(filename.openStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null) {
        String[] retail = inputLine.split("\t");
        if (retail.length >= 2) {
            ret.put(retail[0].trim(), retail[1].trim());
...
OptionalreadModelFromUrl(URL file, Class clazz)
read Model From Url
try {
    return Optional.of(GSON.fromJson(new InputStreamReader(file.openStream()), clazz));
} catch (IOException e) {
    e.printStackTrace();
return Optional.empty();
StringreadNetFile(String urlstr)
read Net File
InputStream in = null;
try {
    URL url = new URL(urlstr);
    in = url.openStream();
    String txt = readText(in);
    return new String(txt.getBytes("ISO-8859-1"), "UTF-8");
} catch (Exception e) {
    e.printStackTrace();
...
StringreadPage(final String urlStr)
read Page
Objects.requireNonNull(urlStr);
final StringBuilder builder = new StringBuilder();
Scanner in = null;
try {
    in = new Scanner(new URL(urlStr).openStream());
    while (in.hasNextLine()) {
        builder.append(in.nextLine());
        builder.append("\n");
...
StringreadPage(URL url)
Read from a page
return readFromInput(url.openStream());
PropertiesreadProperties(final URL url)
read Properties
Properties listProps = new Properties();
InputStream stream = null;
try {
    stream = url.openStream();
    listProps.load(stream);
} catch (IOException e) {
    throw new RuntimeException(e);
} finally {
...
PropertiesreadProperties(final URL url)
Loads and returns a Properties from the passed URL
Properties p = new Properties();
InputStream is = null;
try {
    is = url.openStream();
    if ("XML".equalsIgnoreCase(getExtension(url))) {
        p.loadFromXML(is);
    } else {
        p.load(is);
...
PropertiesreadProperties(URL resource)
read Properties
Properties properties = new Properties();
InputStream in = null;
try {
    in = resource.openStream();
    in = new BufferedInputStream(in);
    properties.load(in);
} finally {
    try {
...
PropertiesreadPropertyFile(URL url)
This class reads a properties file and replaces constructs surrounded by ${ and } by a system properties specified within the curly brackets.
if (url == null) {
    throw new IllegalArgumentException("URL must not be null.");
try (InputStream inputStream = url.openStream()) {
    Properties properties = new Properties();
    properties.load(inputStream);
    Pattern pattern = Pattern.compile("\\$\\{([\\w.]+)\\}");
    for (Entry<Object, Object> entry : properties.entrySet()) {
...
ListreadResource(final URL filename)
read Resource
final List<String> ret = new ArrayList<String>();
try {
    BufferedReader in = new BufferedReader(new InputStreamReader(filename.openStream()));
    String inputLine;
    while ((inputLine = in.readLine()) != null)
        ret.add(inputLine);
    in.close();
} catch (Exception e) {
...