开发者

FileNotFound Exception for available image in android?

开发者 https://www.devze.com 2023-03-19 16:29 出处:网络
I am trying to read this file in Bitmap http://img.youtube.com/vi/rzqqrYLARCE/1.jpg . On normal PC browser it showing same, but when i read it in Bitmap form it shows me \"

I am trying to read this file in Bitmap http://img.youtube.com/vi/rzqqrYLARCE/1.jpg . On normal PC browser it showing same, but when i read it in Bitmap form it shows me " FileNot Found Exception"

This is my logcat :

375,145


07-13 08:05:38.760: WARN/System.err(1383): java.io.FileNotFoundException: 
07-13 08:05:38.760: WARN/System.err(1383): java.io.FileNotFoundException: http://img.youtube.com/vi/rzqqrYLARCE/1.jpg
07-13 08:05:38.770: WARN/System.err(1383):     at org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1064)
07-13 08:05:38.770: WARN/System.err(1383):     at com.andro.iparty.da开发者_JAVA技巧ta.Util.getBitmapFromURL(Util.java:39)
07-13 08:05:38.770: WARN/System.err(1383):     at com.andro.iparty.VideoGallery$2.run(VideoGallery.java:161)
07-13 08:05:38.770: WARN/System.err(1383):     at java.lang.Thread.run(Thread.java:1058)

My coding approach is :

public static Bitmap getBitmapOrignalSizeFromURL(String src) {
        try {
            URL url = new URL(src);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setDoInput(true);
            connection.connect();
            InputStream input = connection.getInputStream();
            Bitmap myBitmap = BitmapFactory.decodeStream(input);

            return myBitmap;


            // return myBitmap;
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

Please let me know is there any problem with extension(jpg) of file.

thanks to all

0

精彩评论

暂无评论...
验证码 换一张
取 消