get Stream From URL - Android Network

Android examples for Network:URL

Description

get Stream From URL

Demo Code


//package com.java2s;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Main {
    public static InputStream getStreamFromURL(String imageURL) {
        InputStream in = null;/*from  w ww  .  j a v  a 2 s.  co m*/
        try {
            URL url = new URL(imageURL);
            HttpURLConnection connection = (HttpURLConnection) url
                    .openConnection();
            in = connection.getInputStream();

        } catch (Exception e) {
            // TODO Auto-generated catch block  
            e.printStackTrace();
        }
        return in;

    }
}

Related Tutorials