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

InputStreamgetInputStreamForURL(URL url)
get Input Stream For URL
JarURLConnection conn = (JarURLConnection) url.openConnection();
return conn.getInputStream();
InputStreamgetInputStreamForURL(URL url)
get Input Stream For URL
try {
    URLConnection connection = getConnection(url);
    return connection.getInputStream();
} catch (MalformedURLException e) {
    throw new IllegalArgumentException(e);
InputStreamgetInputStreamForURL(URL url)
Get an InputStream from the zip file capable of reading from
JarURLConnection conn = (JarURLConnection) url.openConnection();
return conn.getInputStream();
InputStreamgetInputStreamFromURL(String theFilePath)
get Input Stream From URL
try {
    URL myUrl = new URL(theFilePath);
    InputStream myInputStream = myUrl.openStream();
    return myInputStream;
} catch (Exception ex) {
    System.out.println("### ERROR @ Util.getInputStreamFromURL / " + ex);
    return null;
InputStreamReadergetInputStreamReader(URL url)
get Input Stream Reader
return new InputStreamReader(getInputStream(url));
byte[]getUrlContents(String url)
get Url Contents
URL u = new URL(url);
URLConnection uc = u.openConnection();
return toByteArray(uc.getInputStream());
StringgetUrlContents(String urlString)
get Url Contents
URL url = new URL(urlString);
if (url == null)
    return null;
BufferedReader in = null;
try {
    in = new BufferedReader(new InputStreamReader(url.openStream()));
    StringBuilder urlContents = new StringBuilder();
    String inputLine;
...
ListgetUrlContents(String urlString)
get Url Contents
List<String> contents = new ArrayList<String>();
InputStream is = null;
BufferedReader br = null;
String line;
URL url = null;
try {
    url = new URL(urlString);
    is = url.openStream();
...
StringgetUrlContents(URL url)
get Url Contents
BufferedReader bReader = null;
String contents = null;
try {
    StringBuilder buf = new StringBuilder();
    bReader = new BufferedReader(new InputStreamReader(url.openStream()));
    String inputLine;
    while ((inputLine = bReader.readLine()) != null) {
        buf.append(inputLine);
...
InputStreamopenFileOrURL(String fileNameOrUrl)
open File Or URL
try {
    URL url = new URL(fileNameOrUrl);
    return url.openStream();
} catch (MalformedURLException mfe) {
    InputStream str = new FileInputStream(fileNameOrUrl);
    return str;