get Stream From URL - Java Network

Java examples for Network:URL Download

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;//  ww w .ja  v  a 2s.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