List of usage examples for java.lang OutOfMemoryError getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:com.handlerexploit.news.utils.BitmapLruCache.java
/** * Convenience method to retrieve a bitmap image from a URL over the * network. The built-in methods do not seem to work, as they return a * FileNotFound exception.// www . j ava2 s. c o m * * Note that this does not perform any threading -- it blocks the call while * retrieving the data. * * @param url * The URL to read the bitmap from. * @return A Bitmap image or null if an error occurs. */ public static Bitmap readBitmapFromNetwork(String url) { InputStream inputStream = null; BufferedInputStream bufferedInputStream = null; Bitmap bitmap = null; try { URLConnection conn = new URL(url).openConnection(); conn.connect(); inputStream = conn.getInputStream(); bufferedInputStream = new BufferedInputStream(inputStream, 8192); bitmap = BitmapFactory.decodeStream(bufferedInputStream); } catch (OutOfMemoryError e) { Log.d(TAG, "Ran out of memory.", e); } catch (Throwable e) { if (!e.getClass().equals(UnknownHostException.class)) { Log.d(TAG, "Could not get remote image : " + e.getClass().getSimpleName(), e); } } finally { try { if (inputStream != null) { inputStream.close(); } if (bufferedInputStream != null) { bufferedInputStream.close(); } } catch (IOException e) { Log.d(TAG, "Error closing stream.", e); } } return bitmap; }