我正在尝试在位图http://img.youtube.com/vi/rzqqrYLARCE/1.jpg中读取此文件。 在普通的PC浏览器上它显示相同,但当我以Bitmap形式阅读它时,它显示我“ FileNot Found Exception“
这是我的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.data.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)
我的编码方法是:
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;
}
}
请告诉我文件扩展名(jpg)是否有任何问题。
感谢所有