Java URL to InputStream getInputStream(URLConnection paramURLConnection)

Here you can find the source of getInputStream(URLConnection paramURLConnection)

Description

get Input Stream

License

Open Source License

Declaration

private static InputStream getInputStream(URLConnection paramURLConnection) throws IOException 

Method Source Code

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

import java.io.IOException;
import java.io.InputStream;

import java.net.URLConnection;
import java.util.zip.GZIPInputStream;
import java.util.zip.InflaterInputStream;

public class Main {
    private static InputStream getInputStream(URLConnection paramURLConnection) throws IOException {
        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);
            }/*ww w . j av  a  2 s  . c om*/
        }

        return stream;
    }
}

Related

  1. getInputStream(URL url)
  2. getInputStream(URL url)
  3. getInputStream(URL urlFile)
  4. getInputStream(URLConnection c)
  5. getInputStream(URLConnection connection)
  6. getInputStreamForURL(URL url)
  7. getInputStreamForURL(URL url)
  8. getInputStreamForURL(URL url)
  9. getInputStreamFromURL(String theFilePath)