Java URL to InputStream openURL(String url)

Here you can find the source of openURL(String url)

Description

open stream from URL.

License

Open Source License

Parameter

Parameter Description
url the url

Return

null if invalid url

Declaration

public static InputStream openURL(String url) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.io.InputStream;

import java.net.URL;

public class Main {
    public static final String BIOPORTAL_OPTIONS = "&format=xml&display_links=false";

    /**// w ww .  ja v  a  2 s .c  o  m
     * open stream from URL.
     *
     * @param url the url
     * @return null if invalid url
     */
    public static InputStream openURL(String url) {
        try {
            return new URL(url + BIOPORTAL_OPTIONS).openStream();
        } catch (Exception ex) {
            //COULD NOT OPEN
        }
        return null;
    }
}

Related

  1. openStream(URL url)
  2. openStream(URL url)
  3. openStream(URL url)
  4. openStream(URL url, int connectTimeout, int readTimeout)
  5. openStreamUseCache(URL url)
  6. openURLStream(String in)