我在代码中尝试run codes in IO exception
。
但看起来它不起作用,我不知道为什么。
知道的人,请告诉我如何在发生异常时在catch
例外中运行代码。
谢谢,
p / s:Codes
:
try {
mAlThumbnail.add(BitmapFactory.decodeStream(
(InputStream) new URL(URL).getContent()));
} catch (Exception e) {
// THIS LINE CAN RUN, I CAN SEE DETAIL EXCEPTION
e.printStackTrace();
// THESE LINES CAN NOT RUN, I DON'T KNOW WHY, DON'T SEE ANY LOGS
// if can not load file because of low connection
// should load default image
Log.i("", "SET DEFAULT IMAGE");
mAlThumbnail.add(BitmapFactory.decodeResource(
mContext.getResources(), R.drawable.iv_loading_file_failed));
}
Exception
出现在e.printStackTrace()
:
java.io.IOException:BufferedInputStream已关闭01-07 14:23:08.615
java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)
java.io.BufferedInputStream.available(BufferedInputStream.java:112)
libcore.net.http.UnknownLengthHttpInputStream.available(UnknownLengthHttpInputStream.java:53)
java.io.BufferedInputStream.available(BufferedInputStream.java:114)
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)01-07
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:696) controller.feature_card.GetPreviewDownloadThumbnailAsync.doInBackground(GetPreviewDownloadThumbnailAsync.java:88)
controller.feature_card.GetPreviewDownloadThumbnailAsync.doInBackground(GetPreviewDownloadThumbnailAsync.java:26)
android.os.AsyncTask $ 2.call(AsyncTask.java:287)01-07 14:23:08.620
java.util.concurrent.FutureTask.run(FutureTask.java:234)01-07
android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:230)01-07
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
java.util.concurrent.ThreadPoolExecutor中$ Worker.run(ThreadPoolExecutor.java:573)
java.lang.Thread.run(Thread.java:841)01-07 14:23:08.620
BufferedInputStream关闭01-07 14:23:08.620
java.io.BufferedInputStream.streamClosed(BufferedInputStream.java:118)
java.io.BufferedInputStream.available(BufferedInputStream.java:112)
libcore.net.http.UnknownLengthHttpInputStream.available(UnknownLengthHttpInputStream.java:53)
java.io.BufferedInputStream.available(BufferedInputStream.java:114)
android.graphics.BitmapFactory.nativeDecodeStream(Native Method)01-07
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:623)
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:696)
controller.feature_card.GetPreviewDownloadThumbnailAsync.doInBackground(GetPreviewDownloadThumbnailAsync.java:88)
controller.feature_card.GetPreviewDownloadThumbnailAsync.doInBackground(GetPreviewDownloadThumbnailAsync.java:26)
android.os.AsyncTask $ 2.call(AsyncTask.java:287)01-07 14:23:08.625
java.util.concurrent.FutureTask.run(FutureTask.java:234)01-07
android.os.AsyncTask $ SerialExecutor $ 1.run(AsyncTask.java:230)01-07
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
java.util.concurrent.ThreadPoolExecutor中$ Worker.run(ThreadPoolExecutor.java:573)
java.lang.Thread.run(Thread.java:841)