Java Utililty Methods URL to InputStream

List of utility methods to do URL to InputStream

Description

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

Method

InputStreamgetInputStream(String url, int timeout)
Attempts to obtain an InputStream from the provided url.
final InputStream[] result = new InputStream[1];
try {
    final URLConnection connection = new URL(url).openConnection();
    final Thread streamOpener = new Thread() {
        public void run() {
            try {
                result[0] = connection.getInputStream();
            } catch (IOException e) {
...
InputStreamgetInputStream(URL sourceURL)
get Input Stream
InputStream is = null;
try {
    is = sourceURL.openStream();
} catch (Exception e) {
return is;
InputStreamgetInputStream(URL url)
get Input Stream
if ("file".equals(url.getProtocol())) {
    String path = url.getFile().replace('/', File.separatorChar);
    path = ParseUtil.decode(path);
    return new FileInputStream(path);
} else {
    return url.openStream();
InputStreamgetInputStream(URL url)
get Input Stream
URLConnection conn = url.openConnection();
conn.connect();
return conn.getInputStream();
InputStreamgetInputStream(URL url)
Returns an input stream for the given URL.
if (url.getProtocol().equals("file")) {
    return new FileInputStream(url.getFile());
} else {
    return url.openStream();
InputStreamgetInputStream(URL url)
get Input Stream
if (url == null)
    return null;
try {
    return url.openStream();
} catch (FileNotFoundException e) {
    return null; 
InputStreamgetInputStream(URL urlFile)
Get the input stream from a URL.
InputStream is = null;
try {
    is = new BufferedInputStream(urlFile.openStream());
catch (ConnectException e) {
    throw new java.net.ConnectException("Could not connect to URL: " + urlFile.toExternalForm() + ".");
return is;
...
InputStreamgetInputStream(URLConnection c)
get Input Stream
InputStream is = c.getInputStream();
String enc = c.getContentEncoding();
if ("gzip".equalsIgnoreCase(enc) || "x-gzip".equalsIgnoreCase(enc)) {
    is = new GZIPInputStream(is, TRANSFER_BUFFER);
} else if ("deflate".equalsIgnoreCase(enc)) {
    is = new InflaterInputStream(is, new Inflater(), TRANSFER_BUFFER);
return new BufferedInputStream(is);
...
InputStreamgetInputStream(URLConnection connection)
gets the input stream from an url connection
InputStream in = connection.getInputStream();
String encoding = connection.getContentEncoding();
if (encoding != null) {
    if (encoding.equals("deflate"))
        return new InflaterInputStream(in);
    else if (encoding.equals("gzip"))
        return new GZIPInputStream(in);
    else
...
InputStreamgetInputStream(URLConnection paramURLConnection)
get Input Stream
InputStream stream = paramURLConnection.getInputStream();
String encoding = paramURLConnection.getContentEncoding();
if (encoding != null) {
    encoding = encoding.toLowerCase();
    if (encoding.contains("gzip")) {
        stream = new GZIPInputStream(stream);
    } else if (encoding.contains("deflate")) {
        stream = new InflaterInputStream(stream);
...